DJWoodZ / FS22-Discord-Bot

A Discord bot that posts Farming Simulator 22 Dedicated Server status information such as online players.
MIT License
10 stars 2 forks source link

Fail to create database file #5

Closed idkw closed 6 months ago

idkw commented 6 months ago

Hi,

On a fresh run the database fails to be created using docker compose

fs22-discord-bot-server-1  |
fs22-discord-bot-server-1  | > @djwoodz/fs22-discord-bot@0.1.0 start
fs22-discord-bot-server-1  | > node ./bin/server.js
fs22-discord-bot-server-1  |
fs22-discord-bot-server-1  | Poll interval: 60000 milliseconds
fs22-discord-bot-server-1  | New DB written: /usr/src/app/db/db.json
fs22-discord-bot-server-1  | Logging out
fs22-discord-bot-server-1  | node:fs:581
fs22-discord-bot-server-1  |   return binding.open(
fs22-discord-bot-server-1  |                  ^
fs22-discord-bot-server-1  |
fs22-discord-bot-server-1  | Error: EACCES: permission denied, open '/usr/src/app/db/db.json'
fs22-discord-bot-server-1  |     at Object.openSync (node:fs:581:18)
fs22-discord-bot-server-1  |     at Object.writeFileSync (node:fs:2342:35)
fs22-discord-bot-server-1  |     at initialise (/usr/src/app/bin/server.js:291:8)
fs22-discord-bot-server-1  |     at Object.<anonymous> (/usr/src/app/bin/server.js:306:1)
fs22-discord-bot-server-1  |     at Module._compile (node:internal/modules/cjs/loader:1376:14)
fs22-discord-bot-server-1  |     at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
fs22-discord-bot-server-1  |     at Module.load (node:internal/modules/cjs/loader:1207:32)
fs22-discord-bot-server-1  |     at Module._load (node:internal/modules/cjs/loader:1023:12)
fs22-discord-bot-server-1  |     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
fs22-discord-bot-server-1  |     at node:internal/main/run_main_module:28:49 {
fs22-discord-bot-server-1  |   errno: -13,
fs22-discord-bot-server-1  |   code: 'EACCES',
fs22-discord-bot-server-1  |   syscall: 'open',
fs22-discord-bot-server-1  |   path: '/usr/src/app/db/db.json'
fs22-discord-bot-server-1  | }
DJWoodZ commented 6 months ago

Hi @idkw,

That will be due to the permission settings of the directory structure on the host. Verify the user (uid:gid) of the container (usually 1000:1000) can read/write the file. If not, you must adjust the file permission settings on the host file system, or you could try modifying the docker configuration to use a different user.