Open mklueh opened 7 years ago
The main problem I see above is that in the Meteor server environment, most of that code above is not necessary and probably won't even work. e.g. You don't need the npm DDP library, or the DDPLogin or anything, because on a Meteor server you are already running in the Meteor environment and implicitly connected and authenticated by virtue of being in Meteor server code.
The example code you grabbed is for use in a pure node.js environment (no Meteor APIs, no Fibers, etc), not within Meteor the way you are trying to use it.
One other thing is if your workers will be calling non-Fiber aware async code (using callbacks or promises) then you will need to become acquainted with Meteor.bindEnvironment()
and relatives. Google it, there are a lot of resources out there that explain this stuff.
Hope that helps
Hello, I´m struggeling for days now to get the async stuff working with Meteor.
My usecase:
I want to spin up multiple processes, where each one has to do a certain number of exec calls to other programs, file operations and if possible MongoDB queries. Those processes should run within my meteor application. I don´t want to have extra servers for that.
I´ve tried using "child_process", but as Meteor builds the app and wraps files together, I cannot reference my worker file like in plain node.
meteor-job-collection looks like the best choice so far, but I cannot get the simplest implementation working.
Here is the code of my initializing script
And here my worker script
First of all, the DDPLogin callback does basically nothing. It doesn´t get fired at all, so I´ve decided to remove it for now.
Then I get this error:
I haven´t seen anything with fibers in your examples or in the documentation, so I think it should work without them at all until I call some external APIs or whatever.
Another weird thing is I´m getting the collection "app.jobs.jobs" instead of what I´ve specified "app.jobs" - not important, but weird.
What is wrong with my implementation and why do I get the fiber error with the example code?