R
Railway3mo ago
ne0

container crashed

container worked and everything was working well but container crashed...not sure why..Here's the projectid - 1b883543-ff8a-4389-9f72-1fe4b7b73668
93 Replies
Percy
Percy3mo ago
Project ID: 1b883543-ff8a-4389-9f72-1fe4b7b73668
MantisInABox
MantisInABox3mo ago
Is there anything in the logs that might show why it crashed?
ne0
ne0OP3mo ago
/bin/bash: line 1: web:: command not found container event container restart /bin/bash: line 1: web:: command not found container event container died Also when the app was up, it timedout on few api calls and I tried web: gunicorn app:app --timeout 120 but I am back to web: gunicorn app:app in procfile
MantisInABox
MantisInABox3mo ago
web: is a Procfile thing, you should be able to set your start command to just gunicorn app:web --timeout 120 Railway hasn't supported procfiles in a long time
ne0
ne0OP3mo ago
File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 402, in import_app app = getattr(mod, name) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'app' has no attribute 'web' Failed to find attribute 'web' in 'app'. [2024-09-13 14:09:51 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 14:09:51 +0000] [1] [INFO] Shutting down: Master [2024-09-13 14:09:51 +0000] [1] [INFO] Reason: App failed to load. container event container restart [2024-09-13 14:09:52 +0000] [1] [INFO] Starting gunicorn 20.1.0 [2024-09-13 14:09:52 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2024-09-13 14:09:52 +0000] [1] [INFO] Using worker: sync [2024-09-13 14:09:52 +0000] [4] [INFO] Booting worker with pid: 4 Traceback (most recent call last): File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 402, in import_app app = getattr(mod, name) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'app' has no attribute 'web' Failed to find attribute 'web' in 'app'. [2024-09-13 14:09:52 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 14:09:52 +0000] [1] [INFO] Shutting down: Master [2024-09-13 14:09:52 +0000] [1] [INFO] Reason: App failed to load. container event container died [2024-09-13 14:09:53 +0000] [1] [INFO] Starting gunicorn 20.1.0 [2024-09-13 14:09:53 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2024-09-13 14:09:53 +0000] [1] [INFO] Using worker: sync [2024-09-13 14:09:53 +0000] [4] [INFO] Booting worker with pid: 4 Traceback (most recent call last): File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 402, in import_app app = getattr(mod, name) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'app' has no attribute 'web' Failed to find attribute 'web' in 'app'. [2024-09-13 14:09:53 +0000] [4] [INFO] Worker exiting (pid: 4) container event container restart [2024-09-13 14:09:54 +0000] [1] [INFO] Shutting down: Master [2024-09-13 14:09:54 +0000] [1] [INFO] Reason: App failed to load. [2024-09-13 14:09:55 +0000] [1] [INFO] Starting gunicorn 20.1.0 [2024-09-13 14:09:55 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2024-09-13 14:09:55 +0000] [1] [INFO] Using worker: sync [2024-09-13 14:09:55 +0000] [4] [INFO] Booting worker with pid: 4 Traceback (most recent call last): File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 402, in import_app app = getattr(mod, name) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'app' has no attribute 'web' Failed to find attribute 'web' in 'app'. [2024-09-13 14:09:55 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 14:09:55 +0000] [1] [INFO] Shutting down: Master [2024-09-13 14:09:55 +0000] [1] [INFO] Reason: App failed to load. container event container died [2024-09-13 14:09:56 +0000] [1] [INFO] Starting gunicorn 20.1.0 [2024-09-13 14:09:56 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2024-09-13 14:09:56 +0000] [1] [INFO] Using worker: sync [2024-09-13 14:09:56 +0000] [4] [INFO] Booting worker with pid: 4 Traceback (most recent call last): File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 402, in import_app app = getattr(mod, name) ^^^^^^^^^^^^^^^^^^ AttributeError: module 'app' has no attribute 'web' Failed to find attribute 'web' in 'app'. [2024-09-13 14:09:56 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 14:09:56 +0000] [1] [INFO] Shutting down: Master [2024-09-13 14:09:56 +0000] [1] [INFO] Reason: App failed to load. container event container died [2024-09-13 14:09:57 +0000] [1] [INFO] Using worker: sync
MantisInABox
MantisInABox3mo ago
Can you share your repo? Your application might be called app and not web, in which case, you would use app:app
Brody
Brody3mo ago
yes we do
ne0
ne0OP3mo ago
That is true. I am restarting with app:app Now the app is up. testing the api calls to see if it times out Same issue DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): feed-api.cielo.finance:443 [2024-09-13 14:16:51 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:4) [2024-09-13 14:16:51 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 14:16:51 +0000] [5] [INFO] Booting worker with pid: 5 It is a worker timeout Check the update
Brody
Brody3mo ago
how long do you expect a single request to take
ne0
ne0OP3mo ago
it depends on the response but should not take more than 5-7 seconds tbh
Brody
Brody3mo ago
when testing, how many RPS are you doing?
ne0
ne0OP3mo ago
what is RPS? locally it works
Brody
Brody3mo ago
requests per second
ne0
ne0OP3mo ago
It is adata analysis application hitting many different apis so def. 100 req/sec
Brody
Brody3mo ago
then you are likely running into issues with having run gunicorn with sync workers start it with the uvicorn event worker
ne0
ne0OP3mo ago
how do I do it?
Brody
Brody3mo ago
what's your current start command
ne0
ne0OP3mo ago
gunicorn app:app --timeout 120 gunicorn app:app --timeout 120
Brody
Brody3mo ago
no need to ping reply what kind of app? fastapi, flask?
ne0
ne0OP3mo ago
flask
Brody
Brody3mo ago
your start command would become gunicorn app:app --timeout 120 --worker-class eventlet you will also need to make sure eventlet is in your requirements.txt file
ne0
ne0OP3mo ago
Here's my current req Flask==2.0.3 Werkzeug==2.0.3 Jinja2==3.0.3 itsdangerous==2.0.1 click==8.0.4 gunicorn==20.1.0 requests==2.26.0 prettytable==2.5.0 Flask-Login==0.5.0 what version should I use for eventlet
Brody
Brody3mo ago
the latest is probably fine
ne0
ne0OP3mo ago
ok, made changes and redeploying Error: class uri 'eventlet' invalid or not found: [Traceback (most recent call last): File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 99, in load_class mod = importlib.import_module('.'.join(components)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/geventlet.py", line 20, in <module> from eventlet.wsgi import ALREADY_HANDLED as EVENTLET_ALREADY_HANDLED ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' (/opt/venv/lib/python3.11/site-packages/eventlet/wsgi.py) ] container event container died
Brody
Brody3mo ago
do you have it in your requirements.txt?
ne0
ne0OP3mo ago
Flask==2.0.3 Werkzeug==2.0.3 Jinja2==3.0.3 itsdangerous==2.0.1 click==8.0.4 gunicorn==20.1.0 requests==2.26.0 prettytable==2.5.0 Flask-Login==0.5.0 eventlet==0.33.3
Brody
Brody3mo ago
whats your start command
ne0
ne0OP3mo ago
shoujd I use gevent?
Brody
Brody3mo ago
^
ne0
ne0OP3mo ago
gunicorn app:app --timeout 120 --worker-class eventlet I have a Procfile does it matter for Railway
Brody
Brody3mo ago
no, we support procfiles okay try gevent
ne0
ne0OP3mo ago
trying now invalid type: string "gunicorn --timeout 120 --worker-class gevent app:app", expected a ma did I get format right?
Brody
Brody3mo ago
try moving app:app to after gunicorn
ne0
ne0OP3mo ago
context: 5f53c0eeaf434d6d998e9ed8ac0a2c0f Nixpacks build failed Error: Reading Procfile Caused by: invalid type: string "gunicorn app:app --timeout 120 --worker-class gevent", expected a map just way beyond my understanding... gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/nix/store/wwg6376ymkhpjxy6c3w9gkbhv6l2gmqy-libxcrypt-4.4.36/include -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -DEV_USE_REALTIME=1 -DEV_USE_MONOTONIC=1 -DEV_USE_FLOOR=1 -Isrc/gevent/libev -I/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/include/python3.11 -I/root/.nix-profile/include/python3.11 -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/src/gevent/libev -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps/libev -Isrc/gevent -Isrc/gevent/libev -Isrc/gevent/resolver -I. -I/opt/venv/include -I/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/include/python3.11 -c src/gevent/libev/callbacks.c -o build/temp.linux-x86_64-cpython-311/src/gevent/libev/callbacks.o #11 103.8 gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/nix/store/wwg6376ymkhpjxy6c3w9gkbhv6l2gmqy-libxcrypt-4.4.36/include -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -DEV_USE_REALTIME=1 -DEV_USE_MONOTONIC=1 -DEV_USE_FLOOR=1 -Isrc/gevent/libev -I/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/include/python3.11 -I/root/.nix-profile/include/python3.11 -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/src/gevent/libev -I/tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps/libev -Isrc/gevent -Isrc/gevent/libev -Isrc/gevent/resolver -I. -I/opt/venv/include -I/nix/store/k3701zl6gmx3la7y4dnflcvf3xfy88kh-python3-3.11.9/include/python3.11 -c src/gevent/libev/corecext.c -o build/temp.linux-x86_64-cpython-311/src/gevent/libev/corecext.o #11 103.8 In file included from src/gevent/libev/libev.h:9, #11 103.8 from src/gevent/libev/corecext.c:1319: #11 103.8 /tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps/libev/ev.c:580:48: warning: "/" within comment [-Wcomment] #11 103.8 580 | /#define MIN_INTERVAL 0.00000095367431640625 /* 1/2**20, good till 2200 */ #11 103.8 | #11 103.8 /tmp/pip-install-mht4g7p5/gevent_7b95d12f6294466681fc5ce8f6126ea3/deps/libev/ev.c: In function ‘ecb_binary32_to_binary16’: gone back to eventlet File "/opt/venv/lib/python3.11/site-packages/eventlet/greenio/base.py", line 32, in <module> socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/venv/lib/python3.11/site-packages/eventlet/timeout.py", line 166, in wrap_is_timeout base.istimeout = property(lambda : True) ^^^^^^^^^^^^^^^ TypeError: cannot set 'is_timeout' attribute of immutable type 'TimeoutError' ] container event container died can I use python-3.9.7
Brody
Brody3mo ago
yes, set it in a runtime.txt file
ne0
ne0OP3mo ago
I did that but no idea how to resolve the issue with timeouts neither gevent or eventlet is working on railway
Brody
Brody3mo ago
is your app now using gevent
ne0
ne0OP3mo ago
gevent had build issues so I went back to eventlet but eventlet is crashing the docker Error: class uri 'eventlet' invalid or not found:
Brody
Brody3mo ago
you woud need to get one of them working
ne0
ne0OP3mo ago
runtime.txt does not seem to be getting picked up
Brody
Brody3mo ago
why do you say that
ne0
ne0OP3mo ago
File "/opt/venv/lib/python3.11 using python3.11
Brody
Brody3mo ago
i cant verify that, you are about to delete the service
ne0
ne0OP3mo ago
I deleted the service started a new one. and I got things back to a place where it is working not using eventlet or gevent just timeout I want to see if the error persists atleast now I don't have build issues or deployment issues
Brody
Brody3mo ago
this wasnt an issue with railway so the timeout issue isnt going to change
ne0
ne0OP3mo ago
no timeouts locally local dev works fine
Brody
Brody3mo ago
you are not running sync workers locally are you sure this is flask?
ne0
ne0OP3mo ago
Yes app = Flask(name) same error [2024-09-13 16:16:28 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:4) [2024-09-13 16:16:28 +0000] [4] [INFO] Worker exiting (pid: 4) [2024-09-13 16:16:28 +0000] [5] [INFO] Booting worker with pid: 5
Brody
Brody3mo ago
you need to use an async worker
ne0
ne0OP3mo ago
that will require changes ot my code? I just want to replicate my local environment on railway
Brody
Brody3mo ago
im not sure in a production environment you must use gunicorn
ne0
ne0OP3mo ago
yes that works
Brody
Brody3mo ago
and in your case you also need to use async workers
ne0
ne0OP3mo ago
but the moment I add eventlet, it is not even building the moment I add gevent, docker is crashing
Brody
Brody3mo ago
try gthread then
ne0
ne0OP3mo ago
increasaed timeout sufficiently large so that works but towards the end, the final request the response got chopped off is there a limit on the size of response for railway?
Brody
Brody3mo ago
no, only a 5 minute time limit
ne0
ne0OP3mo ago
this was the last step before rendering if you see logs
Brody
Brody3mo ago
increasing the time-out here is just a Band-Aid solution
ne0
ne0OP3mo ago
still dont kknow why railway has issue. works fine on local works well on a vps server fails on railway
Brody
Brody3mo ago
that not not indicate an issue with railway, that indicates an issue with your configurations on railway you need to use an async worker so that your app can handle more then 3 requests concurrently
ne0
ne0OP3mo ago
yea, will need to implement celery and redis but was hoping that I can do that later. Maybe for now, I just use VPS and evaluate railway later on
Brody
Brody3mo ago
you can do celery and redis later, right now you need to use an async worker
ne0
ne0OP3mo ago
didn't we try that? eventlet and gevent both crash the docker for whatever reason
Brody
Brody3mo ago
you have something misconfigured and will need to look into why that's happening
ne0
ne0OP3mo ago
I'll modify the code to see if it works by importing asyncio & aiohttp and adding async with in front of all my request fetch functions Figured out a way. Is there a way to hard refresh a web page? feels like it is serving some cached version
Brody
Brody3mo ago
railway doesnt do any asset caching, is it behind cloudflare?
ne0
ne0OP3mo ago
I migrated the Flask App to NodeJS app is the startup command - web: node app.js container is failing right now Build is successful
Brody
Brody3mo ago
please provide the error
ne0
ne0OP3mo ago
/bin/bash: line 1: web:: command not found container event container died
Brody
Brody3mo ago
what is the contents of your procfile
ne0
ne0OP3mo ago
web: node app.js
Brody
Brody3mo ago
I'll check back with this when I'm back at the computer so I can view your logs, I don't think you are sending me the correct error
ne0
ne0OP3mo ago
\
No description
Brody
Brody3mo ago
wait, aren't you deploying from a Dockerfile? why do you have a procfile
ne0
ne0OP3mo ago
I connected my github project from railway railway handles everything I can remove the procfile you want me to try that?
Brody
Brody3mo ago
haha slow down there
ne0
ne0OP3mo ago
ok, let me know trying my luck ...
Brody
Brody3mo ago
send me your Dockerfile please
ne0
ne0OP3mo ago
How do I do it? I only have the node dev environment on my end. Then I commit my changes to Github. Railway auto deploys
Brody
Brody3mo ago
you do not have a Dockerfile?
ne0
ne0OP3mo ago
Nope Never had one for flask app to Didn’t know we need one
Brody
Brody3mo ago
delete your Procfile
ne0
ne0OP3mo ago
ok deleted what about the start command in update config?
Brody
Brody3mo ago
you should have a start script in your package.json
ne0
ne0OP3mo ago
"scripts": { "start": "node app.js", "dev": "app.js", "test": "echo "Error: no test specified" && exit 1" }, yea, it has always been there
Brody
Brody3mo ago
then you have no need for a procfile
ne0
ne0OP3mo ago
ok. but I am still getting the same problem
Brody
Brody3mo ago
thats not valid syntax
No description
ne0
ne0OP3mo ago
what should I enter in there? just node app.js? figured it out. TY for your help!
Brody
Brody3mo ago
no problem!
ne0
ne0OP2mo ago
when you upgrade the plan, does the app needs to be redeloyed to take advantage of the new RAM etc?
Brody
Brody2mo ago
yes it does
Want results from more Discord servers?
Add your server