Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
Cómo ejecutar gunicorn desde una carpeta que no es la carpeta del proyecto django

Cloné un proyecto en mi carpeta de inicio, llamémoslo /home/telessaude . Entonces, la raíz del proyecto se encuentra en /home/telessaude/telessaude_branch_master

Si estoy dentro de la carpeta de inicio del proyecto Django ( /home/telessaude/telessaude_branch_master ) y emito un comando gunicorn como

gunicorn -w 2 -b 0.0.0.0:8000 telessaude.wsgi_dev:application --reload --timeout 900

gunicorn comienza y funciona bien. Sin embargo... si trato de ejecutar el mismo comando en un directorio anterior (/home/telessaude), obtengo el siguiente error:

 telessaude@ubuntu:~$ gunicorn -w 2 -b 0.0.0.0:8000 telessaude.wsgi_dev:application --reload --timeout 900 [2017-03-22 16:39:28 +0000] [10405] [INFO] Starting gunicorn 19.6.0 [2017-03-22 16:39:28 +0000] [10405] [INFO] Listening at: http://0.0.0.0:8000 (10405) [2017-03-22 16:39:28 +0000] [10405] [INFO] Using worker: sync [2017-03-22 16:39:28 +0000] [10410] [INFO] Booting worker with pid: 10410 [2017-03-22 16:39:28 +0000] [10410] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 557, in spawn_worker worker.init_process() File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process self.load_wsgi() File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 136, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 357, in import_app __import__(module) ImportError: No module named telessaude.wsgi_dev

También intenté ejecutar gunicorn en mi carpeta de inicio con

gunicorn -w 2 -b 0.0.0.0:8000 telessaude_branch_master.telessaude.wsgi_dev:application --reload --timeout 900

y

gunicorn -w 2 -b 0.0.0.0:8000 /home/telessaude/telessaude_branch_master/telessaude.wsgi_dev:application --reload --timeout 900

pero ninguno de ellos también funcionó. Alguien me puede decir como arreglar esto? Necesito ejecutar gunicorn desde cualquier carpeta, porque debo agregarlo como un parámetro de "comando" al supervisor.

No estoy usando un entorno virtual.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puede usar el indicador chdir para Gunicorn para cambiar al directorio del proyecto antes de ejecutar su comando.

 gunicorn -w 2 -b 0.0.0.0:8000 --chdir /home/telessaude/telessaude_branch_master telessaude.wsgi_dev:application --reload --timeout 900
over 4 years ago · Santiago Trujillo Report

0

Debe agregar su aplicación django a Python Path.

En el último gunicorn, puedes probar esto:

Si la ruta raíz del proyecto django es /usr/local/src/djangoapp/ .

La ruta settings.py sería por defecto /usr/local/src/djangoapp/djangoapp/settings.py .

 gunicorn \ -c /usr/local/src/djangoapp/gunicorn_config.py \ --env DJANGO_SETTINGS_MODULE=djangoapp.settings \ --pythonpath '/usr/local/src/djangoapp' \ djangoapp.wsgi:application
  • -c ruta del archivo de configuración
  • --env ruta del módulo de settings.py en su proyecto django
  • --pythonpath agrega la ruta de tu proyecto a Python Path settings.html#pythonpath

--env y --pythonpath son obligatorios.

¡La ruta relativa también estará bien!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!