cameri / nostream

A Nostr Relay written in TypeScript
MIT License
736 stars 189 forks source link

[BUG] v1.19 expects settings.json even though it is not required. #157

Closed arunned closed 1 year ago

arunned commented 1 year ago

Describe the bug

v1.19 swiches to settings.yaml file to load settings. however, if the settings.json file is not found, then it gives an error when starting. from log file

Feb 02 22:12:06 ip-172-31-31-228 node[2759]: Error: ENOENT: no such file or directory, watch '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json' Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at FSWatcher. (node:internal/fs/watchers:247:19) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Object.watch (node:fs:2304:36) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at SettingsStatic.watchSettings (/home/ubuntu/nostream-1.19.0/dist/src/utils/settings.js:104:26) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at App.run (/home/ubuntu/nostream-1.19.0/dist/src/app/app.js:34:51) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Object. (/home/ubuntu/nostream-1.19.0/dist/src/index.js:33:30) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Module._compile (node:internal/modules/cjs/loader:1239:14) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Module._extensions..js (node:internal/modules/cjs/loader:1293:10) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Module.load (node:internal/modules/cjs/loader:1096:32) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Module._load (node:internal/modules/cjs/loader:935:12) Feb 02 22:12:06 ip-172-31-31-228 node[2759]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12) { Feb 02 22:12:06 ip-172-31-31-228 node[2759]: errno: -2, Feb 02 22:12:06 ip-172-31-31-228 node[2759]: syscall: 'watch', Feb 02 22:12:06 ip-172-31-31-228 node[2759]: code: 'ENOENT', Feb 02 22:12:06 ip-172-31-31-228 node[2759]: path: '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json', Feb 02 22:12:06 ip-172-31-31-228 node[2759]: filename: '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json' Feb 02 22:12:06 ip-172-31-31-228 node[2759]: } Feb 02 22:12:06 ip-172-31-31-228 node[2759]: Node.js v19.4.0 Feb 02 22:12:06 ip-172-31-31-228 systemd[1]: nostr.service: Main process exited, code=exited, status=1/FAILURE Feb 02 22:12:06 ip-172-31-31-228 systemd[1]: nostr.service: Failed with result 'exit-code'. Feb 02 22:12:06 ip-172-31-31-228 systemd[1]: nostr.service: Consumed 1.648s CPU time. Feb 02 22:12:11 ip-172-31-31-228 systemd[1]: nostr.service: Scheduled restart job, restart counter is at 1. Feb 02 22:12:11 ip-172-31-31-228 systemd[1]: Stopped NOSTR relay daemon. Feb 02 22:12:11 ip-172-31-31-228 systemd[1]: nostr.service: Consumed 1.648s CPU time. Feb 02 22:12:11 ip-172-31-31-228 systemd[1]: Started NOSTR relay daemon. Feb 02 22:12:13 ip-172-31-31-228 node[2769]: 2023-02-02T22:12:13.134Z primary:app-primary starting Feb 02 22:12:13 ip-172-31-31-228 node[2769]: 2023-02-02T22:12:13.137Z primary:app-primary started Feb 02 22:12:13 ip-172-31-31-228 node[2769]: node:internal/fs/watchers:255 Feb 02 22:12:13 ip-172-31-31-228 node[2769]: throw error; Feb 02 22:12:13 ip-172-31-31-228 node[2769]: ^ Feb 02 22:12:13 ip-172-31-31-228 node[2769]: Error: ENOENT: no such file or directory, watch '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json' Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at FSWatcher. (node:internal/fs/watchers:247:19) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Object.watch (node:fs:2304:36) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at SettingsStatic.watchSettings (/home/ubuntu/nostream-1.19.0/dist/src/utils/settings.js:104:26) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at App.run (/home/ubuntu/nostream-1.19.0/dist/src/app/app.js:34:51) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Object. (/home/ubuntu/nostream-1.19.0/dist/src/index.js:33:30) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Module._compile (node:internal/modules/cjs/loader:1239:14) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Module._extensions..js (node:internal/modules/cjs/loader:1293:10) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Module.load (node:internal/modules/cjs/loader:1096:32) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Module._load (node:internal/modules/cjs/loader:935:12) Feb 02 22:12:13 ip-172-31-31-228 node[2769]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:84:12) { Feb 02 22:12:13 ip-172-31-31-228 node[2769]: errno: -2, Feb 02 22:12:13 ip-172-31-31-228 node[2769]: syscall: 'watch', Feb 02 22:12:13 ip-172-31-31-228 node[2769]: code: 'ENOENT', Feb 02 22:12:13 ip-172-31-31-228 node[2769]: path: '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json', Feb 02 22:12:13 ip-172-31-31-228 node[2769]: filename: '/home/ubuntu/nostream-1.19.0/dist/src/.nostr/settings.json' Feb 02 22:12:13 ip-172-31-31-228 node[2769]: }

To Reproduce Steps to reproduce the behavior:

  1. Run command '...'
  2. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

Logs If applicable, attach log messages showing the bug and context when the bug happened.

Additional context Add any other context about the problem here.

nohea commented 1 year ago

confirmed. I got the error on a new install. After i did:

touch .nostr/settings.json
npm run dev

... it started up

nohea commented 1 year ago

never mind - i found the problem in src/utils/settings.ts it has to be settings.yaml , not .yml

if i renamed the file, it runs

antonleviathan commented 1 year ago

This PR fixes this. If the issue persists please let us know.