djangonginxgunicornupstart

Upstart Gunicorn doesn't working


Hi I am a south korean student :)

I am studing staging, production test using nginx, gunicorn

first I want run gunicorn using socket

gunicorn --bind unix:/tmp/tddtest.com.socket testlists.wsgi:applicaion

and It shows

[2016-06-26 05:33:42 +0000] [27861] [INFO] Starting gunicorn 19.6.0
[2016-06-26 05:33:42 +0000] [27861] [INFO] Listening at:  unix:/tmp/tddgoat1.amull.net.socket (27861)
[2016-06-26 05:33:42 +0000] [27861] [INFO] Using worker: sync
[2016-06-26 05:33:42 +0000] [27893] [INFO] Booting worker with pid: 27893

and I running function test in local repository

python manage.py test func_test

and I was working!

Creating test database for alias 'default'...
..
----------------------------------------------------------------------
Ran 2 tests in 9.062s

OK
Destroying test database for alias 'default'...

and I want auto start gunicorn when I boot server

So I decide to using Upstart(in ubuntu)

In /etc/init/tddtest.com.conf

description "Gunicorn server for tddtest.com"

start on net-device-up
stop on shutdown

respawn

setuid elspeth
chdir /home/elspeth/sites/tddtest.com/source/TDD_Test/testlists/testlists

exec gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application

(path of wsgi.py is)

/sites/tddtest.com/source/TDD_Test/testlists/testlists

and I command

sudo start tddtest.com

It shows

tddtest.com start/running, process 27905

I think it is working

but I running function test in local repository

python manage.py test func_test

but it show

======================================================================
FAIL: test_can_start_a_list_and_retrieve_it_later (functional_tests.tests.NewVisitorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/Users/hanminsoo/Documents/TDD_test/TDD_Test/superlists/functional_tests/tests.py", line 38, in test_can_start_a_list_and_retrieve_it_later
self.assertIn('To-Do', self.browser.title)
AssertionError: 'To-Do' not found in 'Error'

----------------------------------------------------------------------
Ran 2 tests in 4.738s

THE GUNICORN IS NOT WORKING ㅠ_ㅠ

I want look process

ps aux

but I can't found gunicorn process

[...]
ubuntu   24387  0.0  0.1 105636  1700 ?        S    02:51   0:00     sshd: ubuntu@pts/0
ubuntu   24391  0.0  0.3  21284  3748 pts/0    Ss   02:51   0:00 -bash
root     24411  0.0  0.1  63244  1800 pts/0    S    02:51   0:00 su -     elspeth
elspeth  24412  0.0  0.4  21600  4208 pts/0    S    02:51   0:00 -su
root     26860  0.0  0.0  31088   960 ?        Ss   04:45   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   26863  0.0  0.1  31524  1872 ?        S    04:45   0:00 nginx: worker process
elspeth  28005  0.0  0.1  17160  1292 pts/0    R+   05:55   0:00 ps aux

I can't found problem...

please somebody help me thankyou :)


Solution

  • Please modify your upstart script as follows:

    exec /home/elspeth/.pyenv/versions/3.5.1/envs/sites/bin/gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application
    

    If that does not work it could very well be because the /home/elspeth/.pyenv/ folder is inaccessible please check it's permission. If permissions are found to be correct and you are continuing to have problems try this:

    script
       cd /home/elspeth/sites/tddtest.com/source/TDD_Test/testlists/testlists
       /home/elspeth/.pyenv/versions/3.5.1/envs/sites/bin/gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application
    
    end script