Understanding Heroku server status 143

HerokuDeploymentServer Side

Heroku Problem Overview


I'm wondering about Heroku server status and can't find any documentation about this topic.

Example:

Process exited with status 143

Can anyone explain this example? And where would I find resources for future reference?

Heroku Solutions


Solution 1 - Heroku

Exit code 143 means that your process was terminated by a SIGTERM. This is generally sent when you do any commands that require your dynos to restart (config:set, restart, scale down...).

Solution 2 - Heroku

It is an idle state when it does not receive any request for a while. When it receives a request it will start again.

Solution 3 - Heroku

Daily restarts is a regularly Heroku dynos lifecycle activity:

Heroku automatic dyno restarts

Solution 4 - Heroku

It is due to the heroku app stopped by dyno. So you have to restrat the app. You can type heroku restart in the terminal. Also heroku restart --app application_name

Solution 5 - Heroku

None of the answers are addressing this. It is definitely not good to be getting "process exited with status 143". It's a sign that your app is not doing things correctly.

Check out this page from the Heroku docs, specifically the sections on restarting and shutdown.


Basically, there are a number of reasons why your dyno may be restarted. Heroku does automatically restart your dyno every 24 hours, (manual restarts and deploys will reset this 24 hour period) but it can also restart your dyno for other reasons.

It's important to understand that it can be terminated at any given time, and your app needs to be designed with this in mind. For example, say you have a worker process that works some queue, popping items from the queue and doing some work on them. Wouldn't it be bad if you popped the items but then the app terminated and you couldn't do the work? Or do you have some lines of code where it might be bad if the app stopped in the middle of their execution?


Heroku does not just yank the power cord on your app; it sends a SIGTERM signal. Heroku also says (in the above link) that it's a bad idea to ignore that signal. If you're getting "process exited with status 143", it means you're not listening for that signal (for python anyway).

If you're not doing anything in your code to listen for this signal, then you're playing a dangerous game (unless it's okay for your app to be terminated at any point in its execution).


For a python app, if you don't tap into the SIGTERM signal, your app is terminated immediately (as soon as Heroku sends that signal), and you get a "process exited with status 143". Not good.

If however, you tap into that signal, then your app gets 30s to gracefully shutdown before it'll be terminated, which is ample time to finish up any work you were doing. To basically stop doing new work, and complete what you're doing if you know it'll take <30s, or put back unfinished work onto a queue, and then exit, or break whatever loop you were in. You should get "process exited with status 0". That's good.

Also, if you did tap into the signal but you don't exit in 30s, then you get an "Error R12 (Exit timeout) -> At least one process failed to exit within 30 seconds of SIGTERM", and the app is terminated with SIGKILL. You get a "process exited with status 137". Also not good.

In the above link (in the shutdown section), they give an example in ruby of how to tap into that signal. And here is an example in python.

Solution 6 - Heroku

Restart the dyno, which causes the dyno to receive SIGTERM. use this command

heroku restart worker.1

and then

heroku logs

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTien NguyenView Question on Stackoverflow
Solution 1 - HerokuEric FodeView Answer on Stackoverflow
Solution 2 - HerokuPawan VView Answer on Stackoverflow
Solution 3 - HerokuAndriy KryvtsunView Answer on Stackoverflow
Solution 4 - Herokuwangwu jinView Answer on Stackoverflow
Solution 5 - HerokuPeter ParkerView Answer on Stackoverflow
Solution 6 - HerokuThasni IqbalView Answer on Stackoverflow