1

I'm trying to run a Worker process on Heroku with NO web process.

It is a small node express app. But it does not work unless I have a web process running.

I have a Procfile with

worker node server.js

But I get this error

heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/

I want to run it as a worker process as workers are not restricted to the 30s timeout and should be more efficient. This endpoint is meant to just process 1 intensive task separate from our main API so it makes sense to be setup as a worker.

As per this

https://help.heroku.com/PFSOIDTR/why-am-i-seeing-h12-request-timeouts-high-response-times-in-my-app

Question 2: Have I delegated long-running tasks as background jobs? If you cant make your code run any faster and you simply need more time (i.e. process images, parsing documents, making API calls, etc), you can run them as background jobs on worker dynos. Worker dynos do not face the same 30 second timeout that web dynos do, making them perfect for heavy lifting.

All issues I find on fixing this says scale to web:1

So this leads me to believe express cannot run as a worker only and must be a web process?

AndyJamesN
  • 468
  • 4
  • 14

1 Answers1

1

As per this article on Heroku's website, worker dynos do not expose any ports. If you want to have an endpoint that is reachable through the web, you will have to use a web dyno. You can, though, achieve what you want by communicating web and worker dynos with a queue protocol, as explained in this answer by Ryan Daigle.

Pedro Fracassi
  • 3,342
  • 2
  • 16
  • 33
  • 1
    Thanks, yeah that makes sense. No HTTP calls means Express won't work on anything but Web. I have worked it out by using Redis as a message broker between the Web and Worker processes and its working very well! – AndyJamesN May 03 '20 at 17:57