2

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 or spawn, 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)
dburner
  • 1,007
  • 7
  • 22
  • 1
    Have you considered using a cron job to start the process? That way if it dies you could restart it. –  Jul 30 '15 at 19:41
  • @corey112358 I have considered running the whole worker from a cron. Now that you mention the cron could just keep the worker running. But I think there must be a better solution. – dburner Jul 30 '15 at 19:45

0 Answers0