I have deployed a django app and deployed to Heroku it takes facebook account id's as input through CSV file
and parses information. it works fine in the local server but I am getting the below mentioned error when I try to upload a larger CSV file.
14:12:16 web.1 | 2014-07-17 14:12:16 [30747] [INFO] Using worker: sync
14:12:16 web.1 | 2014-07-17 14:12:16 [30752] [INFO] Booting worker with pid: 30752
14:13:21 web.1 | 2014-07-17 14:13:21 [30747] [CRITICAL] WORKER TIMEOUT (pid:30752)
14:13:21 web.1 | 2014-07-17 03:43:21 [30752] [INFO] Worker exiting (pid: 30752)
14:13:21 web.1 | 2014-07-17 14:13:21 [30841] [INFO] Booting worker with pid: 30
Heroku requests are limited to 30 seconds, if the request take longer than this the router will terminate the request
You can increase the LOG LEVEL of gunicorn to see if there's some error in your process
Example of Procfile with timeout increased to 15 sec
web: gunicorn myproject.wsgi --timeout 15 --keep-alive 5 --log-level debug
Related
I'm trying to start the airflow webserver with an existing application and the latest version (2.2.2). The executor is set as LocalExecutor, the datastore is Postgres, Python v3.9. Upon start up, it launches 4 workers which promptly die. It then spins its wheels continually trying to restart them.
Here's an example of the messages showing a worker starting and dying with signal 11 (segmentation violation). This is all within a second of starting.
Using worker: sync
[2021-11-30 17:29:31 -0500] [12529] [INFO] Booting worker with pid: 12529
[2021-11-30 17:29:31 -0500] [12530] [INFO] Booting worker with pid: 12530
[2021-11-30 17:29:31 -0500] [12531] [INFO] Booting worker with pid: 12531
[2021-11-30 17:29:31 -0500] [12532] [INFO] Booting worker with pid: 12532
Running the Gunicorn Server with:
Workers: 4 sync
Host: 0.0.0.0:8080
Timeout: 120
settings.prepare_engine_args(): Using pool settings. pool_size=5, max_overflow=10, pool_recycle=1800, pid=12529
[WARNING] Worker with pid 12529 was terminated due to signal 11
Any suggestions on how to debug these workers?
I gave up on trying to run Airflow directly on my M1 Mac. I suspect it has something to do with the emulator for the M1 chip, but don't know for sure. I fell back to running Airflow in Docker. It takes a very long time to start, but does run OK that way.
I have a Python + FastAPI restful API project running the free tier of Oracle Cloud VM instance.
I use Gunicorn to serve the api and also installed Nginx just in case it's needed.
I have tested my running project with
curl http://localhost:8000
and I can see my API response.
Now my question is : how can I expose this api endpoint outside on the Internet?
Update 1
I started my Python API project with this command:
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --timeout 1200 -b 0.0.0.0
I saw the messages below:
[2021-05-23 00:40:28 +0000] [3850] [INFO] Starting gunicorn 20.0.2
[2021-05-23 00:40:28 +0000] [3850] [INFO] Listening at: http://0.0.0.0:8000 (3850)
[2021-05-23 00:40:28 +0000] [3850] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2021-05-23 00:40:28 +0000] [3853] [INFO] Booting worker with pid: 3853
[2021-05-23 00:40:28 +0000] [3854] [INFO] Booting worker with pid: 3854
[2021-05-23 00:40:28 +0000] [3857] [INFO] Booting worker with pid: 3857
[2021-05-23 00:40:28 +0000] [3858] [INFO] Booting worker with pid: 3858
[2021-05-23 00:42:04 +0000] [3853] [INFO] Started server process [3853]
[2021-05-23 00:42:04 +0000] [3857] [INFO] Started server process [3857]
[2021-05-23 00:42:04 +0000] [3857] [INFO] Waiting for application startup.
[2021-05-23 00:42:04 +0000] [3858] [INFO] Started server process [3858]
[2021-05-23 00:42:04 +0000] [3858] [INFO] Waiting for application startup.
[2021-05-23 00:42:04 +0000] [3858] [INFO] Application startup complete.
[2021-05-23 00:42:04 +0000] [3853] [INFO] Waiting for application startup.
[2021-05-23 00:42:04 +0000] [3853] [INFO] Application startup complete.
[2021-05-23 00:42:04 +0000] [3857] [INFO] Application startup complete.
[2021-05-23 00:42:04 +0000] [3854] [INFO] Started server process [3854]
[2021-05-23 00:42:04 +0000] [3854] [INFO] Waiting for application startup.
[2021-05-23 00:42:04 +0000] [3854] [INFO] Application startup complete.
Then I copied the IP address from the Compute >> Instances >> Instance Details panel and accessed it from my Chrome. Straightaway, it shows me
Unable to connect
Also read through several articles about using Nginx and tried without any luck.
Update 2
Using curl to access the website from my local machine
$ curl http://168.138.12.192:8000/
curl: (7) Failed to connect to 168.138.12.192 port 8000: No route to host
However, when access the IP directly using curl, I was able to get the default Nginx website.
$ curl http://168.138.12.192
Finally, I found out what I missed:
sudo iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 8000 -j ACCEPT
I have to run this command to open the port 8000(yes, my website is using port 8000).
I thought I have added Ingress Rule to accept tcp 8000, but it turns out that I still need to run the aforementioned command.
I do not quite understand why I need to do it, but it solves the problem.
Did you changed the default html page under /var/www/html directory? If not try customize the html page as per your requirement and see if it works for you or else it would just show the default nginx page when accessed from browser using public IP.
Adding to this, Also check if the port 8000 is allowed in the security list and OS firewall. The default port for http request is 80, you need to change the default port from 80 to 8000 in the config file to make this work. refer this page this might be useful How to Change Apache HTTP Port in Linux.
I'm using :
python 3.6
django==2.1.1
gunicorn==19.9.0
i have done the following:
created a django project called api
created an apiapp (an app in my project)
and i have this code in api_app's apps.py :
from django.apps import AppConfig
from api import settings
class ApiappConfig(AppConfig):
name = 'apiapp'
verbose_name = "random_name"
def ready(self):
self.job()
#classmethod
def job(cls):
### doing whatever here for example :
print(settings.SHARED_VARIABLE)
and the following in api_app's __init__.py:
import os
default_app_config = 'apiapp.apps.ApiappConfig'
i'm creating an API so i am required to use multiple workers when deploying:
gunicorn api.wsgi -w 10
now, my issue is that the function job which is called when the server is started, is getting called 10 times because i'm using 10 gunicorn workers, i would like to call it only once
another thing that i would like to do is to have the
settings.SHARED_VARIABLE variable, shared between the different workers. this variable will be updated only by the worker that will launch the app.py on server start.
Thank you !
gunicorn has a setting to do this: --preload
So, after I add this in settings.py: SHARED_VARIABLE = 'content of SHARED_VARIABLE' (and fixed apiapp/__init__.py to use the real app name), I can run gunicorn with the application loaded only once:
$ gunicorn api.wsgi -w 10 --preload
content of SHARED_VARIABLE
[2018-12-31 10:12:15 +0000] [394] [INFO] Starting gunicorn 19.6.0
[2018-12-31 10:12:15 +0000] [394] [INFO] Listening at: http://127.0.0.1:8000 (394)
[2018-12-31 10:12:15 +0000] [394] [INFO] Using worker: sync
[2018-12-31 10:12:15 +0000] [399] [INFO] Booting worker with pid: 399
[2018-12-31 10:12:15 +0000] [400] [INFO] Booting worker with pid: 400
[2018-12-31 10:12:15 +0000] [401] [INFO] Booting worker with pid: 401
[2018-12-31 10:12:15 +0000] [403] [INFO] Booting worker with pid: 403
[2018-12-31 10:12:15 +0000] [404] [INFO] Booting worker with pid: 404
[2018-12-31 10:12:15 +0000] [405] [INFO] Booting worker with pid: 405
[2018-12-31 10:12:15 +0000] [406] [INFO] Booting worker with pid: 406
[2018-12-31 10:12:15 +0000] [408] [INFO] Booting worker with pid: 408
[2018-12-31 10:12:15 +0000] [410] [INFO] Booting worker with pid: 410
[2018-12-31 10:12:15 +0000] [411] [INFO] Booting worker with pid: 411
I'm trying to deploy my django app on heroku. After following the steps instructed by the official document, the dyno I launched always crashes. Then I went through the whole process, and I think the problem might lie on the gunicorn part.
Following the instruction, I set the Procfile as 'web: unicorn hellodjango.wsgi', and when I $foreman start, it only shows "21:21:07 web.1 | started with pid 77969". It didn't say where the web is launched.
Then I tried to test whether gunicorn is working well. So I tried: "$gunicorn hellodjango.wsgi:application", it indeed doesn't work.
I think the path is correct because in current folder there's a hellodjango folder and inside there's the file wsgi.py.
What might be the problem?
One of the changes in later versions of gunicorn includes not logging to stdout/stderr. Add the argument --log-file=XXX, then examine that log file for what port it's running on.
Try setting your Procfile to:
web: gunicorn hellodjango.wsgi:application
write this in your Procfile:
web: gunicorn hellodjango.wsgi --log-file -
it will log everything to the screen like this:
(your_virtualenv)[~/Projects/myproj]$ foreman start
17:03:57 web.1 | started with pid 79137
17:03:58 web.1 | 2014-10-16 17:03:58 [79137] [INFO] Starting gunicorn 19.0.0
17:03:58 web.1 | 2014-10-16 17:03:58 [79137] [INFO] Listening at: http://0.0.0.0:5000 (79137)
17:03:58 web.1 | 2014-10-16 17:03:58 [79137] [INFO] Using worker: sync
17:03:58 web.1 | 2014-10-16 17:03:58 [79140] [INFO] Booting worker with pid: 79140
I am following Getting Started with Django on Heroku tutorial to deploy my app. First to test locally, I ran foreman start:
| => foreman start
00:47:08 web.1 | started with pid 4465
00:47:09 web.1 | 2013-11-21 00:47:09 [4465] [INFO] Starting gunicorn 18.0
00:47:09 web.1 | 2013-11-21 00:47:09 [4465] [INFO] Listening at: http://0.0.0.0:5000 (4465)
00:47:09 web.1 | 2013-11-21 00:47:09 [4465] [INFO] Using worker: sync
00:47:09 web.1 | 2013-11-21 00:47:09 [4468] [INFO] Booting worker with pid: 4468
Then in Chrome I went to http://0.0.0.0:5000/rides/ (also http://localhost:5000/rides/), it is returning Server Error 500.
My project urls.py:
url(r'^rides/', include('rides.urls')),
url(r'^admin/', include(admin.site.urls)),
Below is my Procfile:
web: gunicorn rides_project.wsgi
requirements.txt:
Django==1.6
South==0.8.3
dj-database-url==0.2.2
dj-static==0.0.5
django-localflavor==1.0
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.1
static==0.4
wsgiref==0.1.2
How can I troubleshoot this? Thank you for your help in advance.
Can you navigate to /admin successfully? If so, I would ensure that your DEBUG setting is set to True so that you can get a traceback through the browser to help determine the root cause of the 500 error.