rossimo / retrobot

MIT License
281 stars 16 forks source link

Startup fails when the data directory has lost+found #30

Closed zikes closed 1 year ago

zikes commented 1 year ago

Apparently fsck will automatically create a lost+found directory on mounted volumes eventually. Since the docker container's configured to mount the volume at /retrobot/data that winds up creating a /retrobot/data/lost+found directory. Retrobot loops through the data directory, but since that directory doesn't contain an info.json it causes the service to crash trying to retrieve game info that isn't there.

2022-10-01T00:53:53Z app[c1a53c37] dfw [info]yarn run v1.22.19
2022-10-01T00:53:53Z app[c1a53c37] dfw [info]$ ts-node src/index.ts
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]online
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]Error: ENOENT: no such file or directory, open 'data/lost+found/info.json'
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at Object.openSync (node:fs:585:3)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at Object.readFileSync (node:fs:453:35)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at getGameInfo (/retrobot/src/gameInfo.ts:36:32)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at /retrobot/src/index.ts:554:26
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at arrayReduce (/retrobot/node_modules/lodash/lodash.js:697:21)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at reduce (/retrobot/node_modules/lodash/lodash.js:9749:14)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at unlockGames (/retrobot/src/index.ts:552:25)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at processTicksAndRejections (node:internal/process/task_queues:96:5)
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]    at async main (/retrobot/src/index.ts:45:5) {
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]  errno: -2,
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]  syscall: 'open',
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]  code: 'ENOENT',
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]  path: 'data/lost+found/info.json'
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]}
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]error Command failed with exit code 1.
2022-10-01T00:54:02Z app[c1a53c37] dfw [info]info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2022-10-01T00:54:03Z app[c1a53c37] dfw [info]Starting clean up.
2022-10-01T00:54:03Z app[c1a53c37] dfw [info]Umounting /dev/vdc from /retrobot/data

The quick fix would be to exclude lost+found from https://github.com/rossimo/retrobot/blob/master/src/index.ts#L551, however I think it might be better if it just skipped the directory if it doesn't contain the info.json file and logged that it did so.

rossimo commented 1 year ago

Fixed with https://github.com/rossimo/retrobot/commit/84de29fd37f4f6bb844e12682f30c65dd9787102