Thursday, 13 June 2019

Doing tasks before heroku nodejs server is ready

When deploying a new release, I would like my server to do some tasks before actually being released and listen to http requests.

Let's say that those tasks take around a minute and are setting some variables: until the tasks are done I would like the users to be redirected to the old release.

Basically do some nodejs work before the server is ready.

I tried a naive approach:

doSomeTasks().then(() => {
  app.listen(PORT);
})

But as soon as the new version is released, all https request during the tasks do not work instead of being redirect to old release.

I have read https://devcenter.heroku.com/articles/release-phase but this looks like I can only run an external script which is not good for me since my tasks are setting cache variables.



from Doing tasks before heroku nodejs server is ready

No comments:

Post a Comment