Skip to content
This repository has been archived by the owner on Mar 31, 2018. It is now read-only.

Clearing cache on restart #17

Open
ILiedAboutCake opened this issue Mar 2, 2015 · 2 comments
Open

Clearing cache on restart #17

ILiedAboutCake opened this issue Mar 2, 2015 · 2 comments
Assignees

Comments

@ILiedAboutCake
Copy link
Owner

Node server doesn't like being restarted sometimes, due to corruptions in the cache. Removing *.json files from cache folder fixes issues.

Also, on first install, it does not check if the cache folder exists, and will crash until created manually.

undefined:53
25271241420,
^
SyntaxError: Unexpected number
at Object.parse (native)
at Object.me.readFileSync (/srv/OverRustle-API/node_modules/jsonfile/lib/jsonfile.js:31:17)
at Object. (/srv/OverRustle-API/index.js:84:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3

@hayksaakian
Copy link
Collaborator

https://github.com/ILiedAboutCake/OverRustle-API/blob/master/index.js#L87 is supposed to write the file when it doesn't exist. so either the check to see if it exists doesn't work like we want, or the write doesn't work like we want.

corrupted files -- i don't know how to detect. i guess best thing we can do is catch the exception, then delete the file and write a clean one.

@ILiedAboutCake
Copy link
Owner Author

Should we just clear the cache on restart? As long as the API is not being restarted every minute it should not be a problem no?

repolling endpoints is cheap, and with the server having its own copy of the redis DB, connection loss is no longer a problem.

fs.js:439
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory './cache/metadata.json'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants