Heroku torchserve app crashed, exited with status 0 - python

I'm deploying torchserve on heroku free dyno. Deploy works fine but the app isn't running properly.
LOG1:
2022-03-17T02:11:10.352655+00:00 heroku[web.1]: Starting process with command `torchserve --start --ncs --model-store model_store --models squeezenet1_1.mar`
2022-03-17T02:11:11.558957+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-03-17T02:11:11.701395+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2022-03-17T02:11:11.896962+00:00 heroku[web.1]: Process exited with status 0
2022-03-17T02:11:12.059922+00:00 heroku[web.1]: State changed from starting to crashed
LOG2:
2022-03-17T05:17:29.472219+00:00 heroku[web.1]: Starting process with command `torchserve --start --ncs --model-store model_store --models squeezenet1_1.mar`
2022-03-17T05:17:30.854303+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2022-03-17T05:17:31.304897+00:00 heroku[web.1]: Process exited with status 0
2022-03-17T05:17:31.364160+00:00 heroku[web.1]: State changed from starting to crashed
Also, my requirements.txt:
-f https://download.pytorch.org/whl/cpu/torch_stable.html
future
psutil
requests
captum
packaging
numpy
cython
wheel
pillow==9.0.1
torch==1.10.0+cpu
torchvision==0.11.1+cpu
torchaudio==0.10.0+cpu
torchtext==0.11.0
torchserve==0.5.3
runtime.txt
python-3.8.12
system.properties
java.runtime.version=1.8.0_322

Problem was torchserve was running in background mode by default.
Adding --foreground to the torchserve command in Procfile fixed this.
(Also, java runtime 11.0.14.1 is required by torchserve)

Related

Starting process with command `gunicorn app:app` Exited with status 126

I have a python flask app deployed to heroku.
After the build completes, this is the log.
2021-05-15T17:58:00.000000+00:00 app[api]: Build started by user xxx
2021-05-15T17:58:39.006534+00:00 app[api]: Deploy 23e180a8 by user xxx
2021-05-15T17:58:39.006534+00:00 app[api]: Release v29 created by xxx
2021-05-15T17:58:39.356233+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-15T17:58:44.631213+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2021-05-15T17:58:46.642208+00:00 heroku[web.1]: Process exited with status 126
2021-05-15T17:58:46.707103+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-15T17:58:46.591536+00:00 app[web.1]: Error: No such file or directory
2021-05-15T17:58:49.000000+00:00 app[api]: Build succeeded
These are the contents in my Procfile
web: gunicorn app:app
I have the main file name as app.py
And these are the requirements.txt
app-version==1.0.1
APScheduler==3.6.3
certifi==2020.12.5
chardet==3.0.4
click==8.0.0
Werkzeug==2.0.0
Flask==2.0.0
gunicorn==20.1.0
idna==2.8
Jinja2==3.0.0
MarkupSafe==2.0.0
notify==0.3.1
notify-run==0.0.13
PyQRCode==1.2.1
pytz==2021.1
requests==2.22.0
selenium==3.141.0
six==1.16.0
tornado==6.1
tzlocal==2.1
urllib3==1.25.11
validate-email==1.3
Added these using pip freeze. Any idea whats going wrong?
https://docs.gunicorn.org/en/latest/run.html
Format for Procfile if you using gunicorn:
gunicorn [OPTIONS] [WSGI_APP]
"web: gunicorn app:app" - it is mean file app.py has function app that run application, and file app.py saved on root of project. Check patch.

Discord Rewrite Bot not working after deploying on Heroku

It used to work fine so far both in heroku and locally. Now it only works locally but doesn't work aftter deploying on heroku. This is the log from Heroku:
2021-04-22T17:41:34.000000+00:00 app[api]: Build succeeded
2021-04-22T17:41:37.853181+00:00 heroku[worker.1]: Starting process with command `python3.9.4 dbot.py`
2021-04-22T17:41:38.485331+00:00 heroku[worker.1]: State changed from starting to up
2021-04-22T17:41:39.356992+00:00 app[worker.1]: bash: python3.9.4: command not found
2021-04-22T17:41:39.416346+00:00 heroku[worker.1]: Process exited with status 127
2021-04-22T17:41:39.485205+00:00 heroku[worker.1]: State changed from up to crashed
I have my requirments.txt file with these dependencies included:
git+https://github.com/Rapptz/discord.py
youtube_dl==2020.03.08
pynacl == 1.3.0
colorlog == 4.1.0
And I have this in my procfile:
worker: python3.9.4 dbot.py
As for my knowledge I think it has something do with the python version which I recently updated to 3.9.4
Instead of putting the version of python into the Procfile simply put:
worker: python dbot.py
If you want to specify a python version for your bot create a runtime.txt file with the following format
python-3.9.4

Stopping all processes with SIGTERM/heroku/discord.py bot

My discord.py-rewrite bot is currently being hosted on heroku. It's been fine for these past few weeks until heroku started going haywire just a few hours ago. Why is this happening?
This is the full error
2020-08-26T22:31:28.999683+00:00 heroku[worker.1]: Relocating dyno to a new server
2020-08-26T22:31:29.006086+00:00 heroku[worker.1]: State changed from up to down
2020-08-26T22:31:29.008558+00:00 heroku[worker.1]: State changed from down to starting
2020-08-26T22:31:42.288485+00:00 heroku[worker.1]: Starting process with command `python skybot.py.py`
2020-08-26T22:31:42.917236+00:00 heroku[worker.1]: State changed from starting to up
2020-08-26T22:31:51.626938+00:00 app[worker.1]: Signed In
2020-08-26T22:32:16.991403+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2020-08-26T22:32:20.126043+00:00 heroku[worker.1]: Process exited with status 0
2020-08-27T03:16:41.956314+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2020-08-27T03:16:42.134827+00:00 heroku[worker.1]: Process exited with status 0
Have I ran out of hours already? Or is this just some common bug in the heroku deployment system. I never made any changes to the script btw. This just happened out of the blue.

Heroku dynos crashing

I readed a lot of questions here in stackoverflow, but I cannot solve my problem.
I have a simples python script (Only a print('Hello World')) and I'm sending it to Heroku, my files are:
Procfile: (I believe the problem is here)
web: python index.py
heroku logs --tail
2020-05-06T16:06:38.000000+00:00 app[api]: Build started by user <myemail>
2020-05-06T16:07:00.948412+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-06T16:07:00.572714+00:00 app[api]: Release v11 created by user <myemail>
2020-05-06T16:07:00.572714+00:00 app[api]: Deploy 4053de7f by user <myemail>
2020-05-06T16:07:07.099124+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-06T16:07:07.103524+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-06T16:07:07.002972+00:00 app[web.1]: Hello World
2020-05-06T16:07:08.000000+00:00 app[api]: Build succeeded
2020-05-06T16:07:13.797877+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-06T16:07:13.619779+00:00 app[web.1]: Hello World
heroku ts
Free dyno hours quota remaining this month: 550h 0m (100%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
=== web (Free): python index.py (1)
web.1: crashed 2020/05/06 13:07:13 -0300 (~ 4m ago)
How we can see, the "Hello World" in log shows that the script runs when I send it to server. But after it, the dyno crashes
in case of Web dyno the application must bind to the port provided by Heroku and defined in the $PORT env variable, where it will receive the incoming requests.
If you need to HTTP traffic try to create a worker node
For example to create a simple Flask app which can receive requests:
from flask import Flask
import os
import logging
try:
app = Flask(__name__)
except Exception as e:
logging.exception("Error at startup")
#app.route('/test')
def test():
logging.info('/test')
return "test Ok"
if __name__ == '__main__':
app.run(debug=False, port=int(os.environ.get("PORT", 5000)), host='0.0.0.0')
Port is set using $PORT on Heroku while locally defaults to 5000

adding clocking support to heroku with python django

This article teaches how to run background jobs in heroku.
I have my clock.py file, in the same directory where Procfile is.
Following is my clock.py file:
from apscheduler.scheduler import Scheduler
from subscription.views import send_subs_mail
sched = Scheduler()
#sched.cron_schedule(day_of_week='sat', hour=23)
def scheduled_job():
print 'This job is run every saturday at 11pm.'
send_subs_mail()
sched.start()
while True:
pass
I have updated my Procfile, to look as follows:
web: newrelic-admin run-program gunicorn hellodjango.wsgi -b 0.0.0.0:$PORT -w 3
clock: python clock.py
Earlier it used to look like:
web: newrelic-admin run-program gunicorn hellodjango.wsgi -b 0.0.0.0:$PORT -w 3
Having done all this, I do the following in my terminal:
heroku ps:scale clock=1
And I get the following error:
Scaling clock processes... failed ! No such type as clock.
I have updated my requirements file, as mentioned in the article.
and here is the heroku logs
2013-05-22T15:52:08.200587+00:00 heroku[web.1]: Starting process with command `newrelic-admin run-program gunicorn hellodjango.wsgi -b 0.0.0.0:48070 -w 3 clock: python clock.py`
2013-05-22T15:52:09.081883+00:00 heroku[web.1]: Process exited with status 0
2013-05-22T15:52:10.691985+00:00 app[web.1]: gunicorn: error: No application module specified.
2013-05-22T15:52:10.683457+00:00 app[web.1]: Usage: gunicorn [OPTIONS] APP_MODULE
2013-05-22T15:52:10.691843+00:00 app[web.1]:
2013-05-22T15:52:12.504514+00:00 heroku[web.1]: Process exited with status 2
2013-05-22T15:52:12.525765+00:00 heroku[web.1]: State changed from crashed to starting
2013-05-22T15:52:12.525765+00:00 heroku[web.1]: State changed from starting to crashed
2013-05-22T15:52:16.198417+00:00 heroku[web.1]: Starting process with command `newrelic-admin run-program gunicorn hellodjango.wsgi -b 0.0.0.0:55149 -w 3 clock: python clock.py`
2013-05-22T15:52:17.343513+00:00 app[web.1]: Usage: gunicorn [OPTIONS] APP_MODULE
2013-05-22T15:52:17.343513+00:00 app[web.1]: gunicorn: error: No application module specified.
2013-05-22T15:52:17.343513+00:00 app[web.1]:
2013-05-22T15:52:18.557818+00:00 heroku[web.1]: State changed from starting to crashed
2013-05-22T15:52:18.542409+00:00 heroku[web.1]: Process exited with status 2
What is wrong?
Each process type should be on it's own line, like so:
web: newrelic-admin run-program gunicorn hellodjango.wsgi -b 0.0.0.0:$PORT -w 3
clock: python clock.py
Hope that helps!

Categories