Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using meteorhacks:cluster my 8 core processor is running the job 8 times #56

Open
jamesgibson14 opened this issue Jun 24, 2015 · 9 comments

Comments

@jamesgibson14
Copy link

I just started testing the Meteorhack:cluster package and the multi-core flag, but when I started up my project syced-cron started running all the jobs 8 times (8 core machine).

@zol
Copy link
Member

zol commented Sep 14, 2015

Hey @jamesgibson14 - Did you find a workaround to this? If not, can you provide a repo with a reproduction?

@jamesgibson14
Copy link
Author

No I didn't, I just turn off multi-core for now.

On Mon, Sep 14, 2015 at 3:41 PM, Zoltan Olah [email protected]
wrote:

Hey @jamesgibson14 https://github.com/jamesgibson14 - Did you find a
workaround to this? If not, can you provide a repo with a reproduction?


Reply to this email directly or view it on GitHub
#56 (comment)
.

@babnik63
Copy link

I have the same problem. ...!

@aesmon
Copy link

aesmon commented Jan 21, 2016

Any updates on this problem ?

@ko0stik
Copy link

ko0stik commented Jan 28, 2016

I had the same issue I managed to circumvent by checking the worker number and the environment:

if (parseInt(process.env.CLUSTER_WORKER_ID, 10) === 1 || process.env.NODE_ENV === 'development') { your tasks }

It's dirty, I'm ashamed to show such code but it worked so far.

@chneau
Copy link

chneau commented Sep 29, 2016

Can we have an update. I'm not really sure but I have 4 clusters on the same computer doing a mongodump. It looks like some of them don't do the task and let only one do the tasks.
I can see this message << SyncedCron: Not running "SaveDatabase" again. >>

After quick log of the process.env.CLUSTER_WORKER_ID on the job, it looks like the last worker do the task.

@sferoze
Copy link

sferoze commented Oct 17, 2016

@ko0stik I am using meteorhacks:cluster package as well on a 2 core system.

To prevent the jobs from being scheduled twice I used the code you posted.

Just wondering if you've had any issues with it? Seems to do the trick

@ko0stik
Copy link

ko0stik commented Oct 23, 2016

Hey @sferoze. I stopped using meteorhacks:cluster a while ago when we switched to Galaxy. But it perfectly worked during the whole time we've been using it (until June 2016 I'd say).

@luixal
Copy link

luixal commented Nov 4, 2016

Same problem and same solution over here.

In fact, We've noticed that process.env.CLUSTER_WORKER_ID is present in all workers but one (the first launched I guess) so this is working for us:

if (!proces.env.CLUSTER_WORKER_ID) {
  // code here runs only in one instance
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants