ChrisWren / grunt-nodemon

Grunt task to run nodemon
MIT License
345 stars 37 forks source link

Backgrounding and stopping backgrounded nodemon task #24

Closed DavidOrchard closed 10 years ago

DavidOrchard commented 10 years ago

I'd like to use grunt to start nodemon in the background, and then stop nodemon afterwards, ala grunt start; grunt stop.

ChrisWren commented 10 years ago

I'm curious what your use case is. I don't how I would keep track of the wild nodemon between grunt start and stop because that is two separate invocations of grunt-nodemon.

— Sent from Mailbox for iPhone

On Wed, Nov 20, 2013 at 11:28 AM, DavidOrchard notifications@github.com wrote:

I'd like to use grunt to start nodemon in the background, and then stop nodemon afterwards, ala grunt start; grunt stop.

Reply to this email directly or view it on GitHub: https://github.com/ChrisWren/grunt-nodemon/issues/24

DavidOrchard commented 10 years ago

My use case is that I'm used to commands affecting background process, ie apachectl start. I want to start a number of servers like redis, node/express. Redis has a way of stopping the running daemon through a cli invoke. One way of communicating information to stop a server is that a server will make a file with a process id that can then be used in the stop operation.

ChrisWren commented 10 years ago

Is nodemon necessary in this equation, or are you just trying to start a node server and then kill it in the background? If so, it might be worth making a separate grunt plugin which runs a command and creates a file to monitor the process which can then be used to stop it as you described. I am just not sure if this functionality belongs in grunt-nodemon, but I am willing to hear you out.

DavidOrchard commented 10 years ago

If you take a look at grunt-express-server, they have an option to start and stop the express server. express:dev is implicitly express:dev:start, and there is an express:dev:stop, where dev is specific instance of an express server. AFAICT, their logic to run in the background is busted because when grunt exits, it kills the spawned process.

There is also grunt-external-daemon which spawns but doesn't track the child for later termination.

The reason I asked on nodemon is because the logic to stop nodemon may be specific to nodemon and you need a specific nodemon invoke to stop. An example of such is stopping redis requires a call through the redis-cli.

ChrisWren commented 10 years ago

I don't think nodemon has any special invoke to stop it unless @remy has something in the works, so grunt-nodemon would have no role in solving this problem. Maybe you could make a grunt-plugin to solve this since the ones you mentioned don't meet your needs.

remy commented 10 years ago

I've got something in the works. I'm trying to get it so it would look like:

var nodemon = require('nodemon');

nodemon.run(options); // whatever they may be

nodemon.emit('stop');
// nodemon.emit('restart'); // and so on.

Though it's a little way out yet, but would may requiring nodemon easy (and testing easier).

DavidOrchard commented 10 years ago

Thanks remy. I think that would be a nice feature to help node incrementally move towards soa.