'Django deployment error "usage: gunicorn [OPTIONS] [APP_MODULE] gunicorn: error: unrecognized arguments: "
I am trying to deploy a Django app on a Linux virtual machine created on Google Computing Engine (GCE). My domain name works fine but the wsgi server does not run because of the error in the title.supervisor.log looks like tis.
.
.
.
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments:
I am having a hard time troubleshooting because it does not tell me where to look into.
The error seems to occur when I run gunicorn_start via commands such as sudo supervisorvtl restart tutorial or chmod +x .../venv/bin/gunicorn_start because I can run the contents of the file directly via my terminal.
This is how my file tree looks like:
/webapp/user
|--- req.txt
|--- venv
|--- tutorial
|-- req.txt
|--manage.py
|--tutorial
.
.
.
|--wsgi.py
|--settings.py
.
.
.
I thought that the cause of this error is in the contents of the gunicorn_start file. So I ran the shell scripts in the file directly in the VM's terminal and the wsgi server seems to be running fine. Here's the result.
[13634] [DEBUG] Current configuration:
config: ./gunicorn.conf.py
wsgi_app: None
bind: ['unix:/home/user/webapp/user/venv/run/gunicorn.sock']
backlog: 2048
workers: 3
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 120
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
reload_extra_files: []
spew: False
check_config: False
print_config: False
preload_app: False
sendfile: None
reuse_port: False
chdir: /home/user/webapp/user/tutorial
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 1000
group: 1001
umask: 0
initgroups: False
tmp_upload_dir: None
secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
forwarded_allow_ips: ['127.0.0.1']
accesslog: None
disable_redirect_access_to_syslog: False
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: -
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
logconfig_dict: {}
syslog_addr: udp://localhost:514
syslog: False
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
dogstatsd_tags:
statsd_prefix:
proc_name: tutorial
default_proc_name: tutorial.wsgi:application
pythonpath: None
paste: None
on_starting: <function OnStarting.on_starting at 0x7fc0ec8c4b80>
on_reload: <function OnReload.on_reload at 0x7fc0ec8c4ca0>
when_ready: <function WhenReady.when_ready at 0x7fc0ec8c4dc0>
pre_fork: <function Prefork.pre_fork at 0x7fc0ec8c4ee0>
post_fork: <function Postfork.post_fork at 0x7fc0ec8d9040>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7fc0ec8d9160>
worker_int: <function WorkerInt.worker_int at 0x7fc0ec8d9280>
worker_abort: <function WorkerAbort.worker_abort at 0x7fc0ec8d93a0>
pre_exec: <function PreExec.pre_exec at 0x7fc0ec8d94c0>
pre_request: <function PreRequest.pre_request at 0x7fc0ec8d95e0>
post_request: <function PostRequest.post_request at 0x7fc0ec8d9670>
child_exit: <function ChildExit.child_exit at 0x7fc0ec8d9790>
worker_exit: <function WorkerExit.worker_exit at 0x7fc0ec8d98b0>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7fc0ec8d99d0>
on_exit: <function OnExit.on_exit at 0x7fc0ec8d9af0>
proxy_protocol: False
proxy_allow_ips: ['127.0.0.1']
keyfile: None
certfile: None
ssl_version: 2
cert_reqs: 0
ca_certs: None
suppress_ragged_eofs: True
do_handshake_on_connect: False
ciphers: None
raw_paste_global_conf: []
strip_header_spaces: False
[2022-05-18 00:55:48 +0000] [13634] [INFO] Starting gunicorn 20.1.0
[2022-05-18 00:55:48 +0000] [13634] [DEBUG] Arbiter booted
[2022-05-18 00:55:48 +0000] [13634] [INFO] Listening at: unix:/home/user/webapp/user/venv/run/gunicorn.sock (13634)
[2022-05-18 00:55:48 +0000] [13634] [INFO] Using worker: sync
[2022-05-18 00:55:48 +0000] [15864] [INFO] Booting worker with pid: 15864
[2022-05-18 00:55:48 +0000] [15865] [INFO] Booting worker with pid: 15865
[2022-05-18 00:55:48 +0000] [15866] [INFO] Booting worker with pid: 15866
[2022-05-18 00:55:48 +0000] [13634] [DEBUG] 3 workers
My gunicorn_start looks like this:
#!/bin/sh
NAME='tutorial'
DJANGODIR=/home/user/webapp/user/tutorial
SOCKFILE=/home/user/webapp/user/venv/run/gunicorn.sock
USER=user
GROUP=user
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=tutorial.settings
DJANGO_WSGI_MODULE=tutorial.wsgi
TIMEOUT=120
cd $DJANGODIR
. ../venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
exec ../venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--chdir /home/user/webapp/yoshi/tutorial \
--name $NAME \
--workers $NUM_WORKERS \
--timeout $TIMEOUT \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file=-
Here's how .conf looks like:
[program:tutorial]
command = /home/user/webapp/user/venv/bin/gunicorn_start
user = user
stdout_logfile = /home/user/webapp/user/venv/logs/supervisor.log
redirect_stderr = true
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
This is how ~/webapp/user/req.txt looks like:
asgiref==3.5.2
cachetools==5.1.0
certifi==2021.10.8
charset-normalizer==2.0.12
Django==4.0.4
google-api-core==2.7.3
google-auth==2.6.6
google-cloud-secret-manager==2.10.0
googleapis-common-protos==1.56.1
grpc-google-iam-v1==0.12.4
grpcio==1.46.1
grpcio-status==1.46.1
gunicorn==20.1.0
idna==3.3
mysql-connector==2.2.9
mysqlclient==2.1.0
proto-plus==1.20.3
protobuf==3.20.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
PyMySQL==1.0.2
requests==2.27.1
rsa==4.8
six==1.16.0
sqlparse==0.4.2
urllib3==1.26.9
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
