Tielman Nieuwoudt Tielman Nieuwoudt - 10 months ago 290
Node.js Question

Deploy only worker dyno to heroku (for firebase-queue)

I want to deploy a NodeJS server on a worker-only dyno on heroku. I've tried several approaches but I always get the error:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

My server does not need to serve files or an API. What is the correct way to deploy to Heroku? Specifically, what is the correct way to deploy only a firebase-queue implementation to Heroku?

My server is dedicated to process work from a queue. It monitors a Firebase location and reacts on changes. Specifically, its a firebase-queue implementation, almost an exact copy of my-queue-worker.js as given in the guide

var Queue = require('firebase-queue');
var firebase = require('firebase');

serviceAccount: '{projectId: 'xx', clientEmail: 'yy', privateKey: 'zz'}',
databaseURL: '<your-database-url>'

var ref = firebase.database().ref('queue');
var queue = new Queue(ref, function(data, progress, resolve, reject) {
// Read and process task data

// Do some work

// Finish the task asynchronously
setTimeout(function() {
}, 1000);


The first important part, as stated by Yoni, is to tell Heroku that you only need a background worker and not a web worker:

worker: node <path_to_your_worker>

The second important part is: Heroku will launch a web dyno by default. To disbable this, run the following commands from the commandline in your directory:

$ heroku ps:scale web=0 worker=1
$ heroku ps:restart

This should fix the problem!