node.js - Add worker to PM2 pool. Don't reload/restart existing workers -
env.: node.js on ubuntu, using pm2 programmatically.
i have started pm2 3 instances via node on main code. suppose use pm2 command line delete 1 of instances. can add worker pool? can done without affecting operation of other workers?
i suppose should use start
method:
pm2.start({ name : 'worker', script : 'api/workers/worker.js', // script run exec_mode : 'cluster', // or fork instances : 1, // optional: scale app 4 max_memory_restart : '100m', // optional: restart app if reaches 100mo autorestart : true }, function(err, apps) { pm2.disconnect(); });
however, if use pm2 monit
you'll see 2 existing instances restarted , no other created. result still 2 running instances.
update doesn't matter if cluster
or fork
-- behavior same.
update 2 command line has scale
option ( https://keymetrics.io/2015/03/26/pm2-clustering-made-easy/ ), don't see method on programmatic api documentation ( https://github.com/unitech/pm2/blob/master/advanced_readme.md#programmatic-api ).
i think can't done in pm2 have exact same problem.
i'm sorry, think solution use else pm2 limited. lack of ability add more workers deal breaker me.
i know can "scale" on command line if using clustering have no idea why can not start more instances if using fork. makes no sense.
Comments
Post a Comment