smart-facility / cognicity-reports-powertrack

cognicity-reports: NodeJS app - Twitter & GNIP PowerTrack support for the CogniCity framework
5 stars 4 forks source link

pm2 (replaces daemonize) #12

Closed matthewberryman closed 8 years ago

matthewberryman commented 8 years ago

Hi @talltom , Here 'tis, my work at getting our powertrack harvester/bot running using pm2. As per the pm2 readme, it has a lot of power for management of node processes, and integrates better with the OS (I have tested on Ubuntu and CentOS with no errors). If you're happy please merge and close.

Cheers, Matthew.

tomasholderness commented 8 years ago

Hi Matthew,

1) Process name, I'm not keen to change from app.js because we already have a CogniCityReportsPowerTrack.js is there no way in PM2 to predefine process name? (edit: I mean arangement/naming of files is a kind of informal NodeJS pattern for an application)

2) package.json requirements - OK great, not a problem. And as its not a dependency it can still be run directly from command line as node app.js config.js?

Thanks.

matthewberryman commented 8 years ago

Hi Tom, 1) I think the informal convention is a little dumb here (a filename should be a bit more descriptive than just "app", IMHO), but anyway, I read further and it turns out you can set this in a .json file that pm2 uses to start the process. So I have left it as app.js and then the name is separately set to "harvester". The added advantage of doing it this way is that I can set a watch option, so if a file (other then .git, node_modules, git hooks or test files) changes then the process gets restarted. This is handy if the code or the config changes. Then a git pull would end in the process restarting. 2) Correct, although if you want it to run in the background manually you would of course need to add an &, and could also use nohup, etc.

Please refer to the latest commit, including documentation file, for the changes.

Cheers, Matthew