Differential / meteor-workers

Spawn headless worker meteor processes to work on async jobs.
80 stars 9 forks source link

Server code run twice on startup #9

Open nelisbijl opened 9 years ago

nelisbijl commented 9 years ago

Not sure if it only concerns the server code

Reproduce:

My output (log msg: 'server/test.js'): => Started proxy.
=> Started MongoDB.
I20150424-08:36:12.203(2)? server/test.js
I20150424-08:36:12.205(2)? MASTER: Requeued 0 jobs. => Started your app.

=> App running at: http://localhost:3000/ I20150424-08:36:12.841(2)? server/test.js I20150424-08:36:12.847(2)? PID 24372: Started 1 monq workers.

Nevtep commented 8 years ago

Same happens to me, this is my log:

=> Started proxy.
=> Started MongoDB.
=> Started your app.

=> App running at: http://localhost:3000/ I20151217-15:55:56.453(-3)? You now have an instance of the bitfinex API object available I20151217-15:55:56.454(-3)? MASTER: Requeued 0 jobs. I20151217-15:55:56.454(-3)? Initialize APIs I20151217-15:55:56.994(-3)? WebSocket Client Connected I20151217-15:55:57.148(-3)? You now have an instance of the bitfinex API object available I20151217-15:55:57.161(-3)? PID 7986: Started 1 monq workers. I20151217-15:55:57.174(-3)? Initialize APIs I20151217-15:55:58.006(-3)? WebSocket Client Connected

lusilva commented 8 years ago

I'm also experiencing this, is this project still active?

elie222 commented 8 years ago

same issue here

noahadler commented 8 years ago

you can solve this by adding an extra check to make sure the process isn't a worker. For instance, instead of: Meteor.startup(function() { if (Meteor.isServer) { /*...*/ } }); try: Meteor.startup(function() { if (Meteor.isServer && Npm.require('cluster').isMaster) { /*...*/ } });