In an OpenShift enviroment how could I run two NodeJS processes (from the nodejs official cartridge), each with its own startup file?
Basicaly I want to make a web application that will sometimes put jobs in a queue. I thought that I should have two proceses: one to handle the web requests and one to handle the jobs processing.
The reason is that I think processing the jobs in a separate process is that I think it could block the front end part if there are many jobs.
These are my solutions so far (but I dont really know if they are good)
- spawn the second process from an action hook (start and restart). I am worried that if the worker process dies it won't be automaticaly restarted
- from the main process call
fork
orspawn
, etc. Same worries as the above - do not use two processes at all, use only one
Other details:
- a job is mainly IO: a few HTTP requests to Google API (5-10 requests per job), also 2 simple requests to mongodb
- at first there wont be many jobs in the queue but its possibly to have many in the future
- I am planning to use kue for the concurent feature and UI feature
- all of these things will be kept on a single server (scaling may occur but its highly unlikely)