108

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?

7 Answers 7

113

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...).

9
  • 3
    Nope not bad at all. It is how heroku tells your app it is time to shut down.
    – Eric Fode
    Commented Apr 3, 2013 at 17:34
  • 3
    @EricFode Where can I find a reference of these status codes? Commented Aug 24, 2013 at 14:24
  • 2
    @GauthamBadhrinathan Those status codes are not heroku specific, they are defined in the man file for what ever app is running. exit 143 and a few other are special in that they are standardized by the unix kernal.
    – Eric Fode
    Commented Aug 27, 2013 at 19:52
  • 5
    For me it was confusing because I would run - Heroku restart - Heroku logs Then my output would show my programs output and the error code AFTER. So it would seem like heroku was scaling down my process, when really it was just logging in an order that I didn't expect. Commented Aug 18, 2014 at 13:33
  • 1
    is it because of free dyno? paying heroku will solve this problem? since @eric was saying 'It is how heroku tells your app it is time to shut down' and paid dyno dont goto sleep Commented Jun 17, 2017 at 8:44
12

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

8

Daily restarts is a regularly Heroku dynos lifecycle activity:

Heroku automatic dyno restarts

1
  • Wondering if the question is about restarting!? Commented Aug 12, 2022 at 6:21
4

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

4

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.

0

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

heroku restart worker.1

and then

heroku logs
0

When I check the logs:

 heroku[web.1]: Idling
 heroku[web.1]: State changed from up to down
 heroku[web.1]: Stopping all processes with SIGTERM
 heroku[web.1]: Process exited with status 143

It clearly says it's because of Idling, but how can prevent that. When I open the web app with URL, Dyno starts the app again. but in my case I use selenium chrome driver in the background and there is no real user.

so there should be a way to check my URL every N-minutes to prevent it from shutting down

I found a New Relic APM add-ons and also http://kaffeine.herokuapp.com/ to resolve it on this post

https://stackoverflow.com/questions/5480337/easy-way-to-prevent-heroku-idling#:~:text=You%20can%20install%20the%20free,preventing%20the%20dyno%20from%20idling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.