I've got a Node.js project that's local to our client machines, and I'd like to be able to monitor a remote location for changes to two files (server.js & logging.js), automatically stop the node server, copy the remotely changed file(s) locally and restart the server using the newly copied local files.
This would be used in our production environment to deploy end-of-sprint tested changes so that we don't have to regularly go run installs for our Service department.
I've tried using Forever & Nodemon, both of which happily monitor the remote file(s) for changes, but only restart the local (unchanged) copy, so those changes don't get propagated to the local copy.
I plan to use Forever in the production environment to help with the occasional local server crash we experience, so ideally any solution could be run via Forever's -c
switch. I've also investigated using their underlying code chokidar, but didn't see the ability to copy files on change.
Our deployment environment is all Windows based, so I'm using Forever-Win, however, we're trying to be platform agnostic with the application we're running.
Possibly something similar to:
forever start --watch \\server\share\server.js --watch \\server\share\logging.js -c [remote monitoring copy locally package name] server.js
I'm hoping to find an NPM package that already exists so I don't have to roll my own.
This SO answer is close to what I'm looking for, but he's monitoring a log file, not the server itself.
This is another SO question that's very similar to the problem I want to solve.