Member 14908485 Ответов: 0

Как создать сервис на centos7 с помощью Python flask uwsgi и nginx


I am trying to build a service with nginx that run uwsgi file.
My service name is “slvv.service” this is my service code

    [Unit]
    Description=uWSGI instance to serve slvv
    After=network.target
    
    [Service]
    User=showeve1
    Group=nginx
    WorkingDirectory=/home/showeve1/www/showevents-ye.com/showevents/slv
    Environment="PATH=/home/showeve1/www/showevents-ye.com/showevents/slv/myprojectenv/bin"
    ExecStart=/home/showeve1/www/showevents-ye.com/showevents/slv/myprojectenv/bin/uwsgi --ini app.ini
    
    [Install]
    WantedBy=multi-user.target


Что я уже пробовал:

When I run this command `sudo systemctl status slvv` on the previous file. I got this error 

    slvv.service: main process exited, code=exited, status=203/EXEC

I have added `/bin/bash`  
   

     ExecStart=/bin/bash /home/showeve1/www/showevents-ye.com/showevents/slv/myprojectenv/bin/uwsgi --ini app.ini

Then I have got this error 

    slvv.service: main process exited, code=exited, status=126/n/a

then I modified the ExecStart  line to become like this:

    ExecStart=/bin/bash 'cd /home/showeve1/www/showevents-ye.com/showevents/slv; source  myprojectenv/bin/activate; uwsgi app.ini'

Then I have got this error:

    slvv.service: main process exited, code=exited, status=127/n/a

Note: I have already updated the System using 

    sudo yum install epel-release -y

also as another solution, I have changed 

    WantedBy=multi-user.target

 
To :

    WantedBy=default.target

But nothing happened.


“app.ini” file. this is Uwsgi code which I call in the above  service: 

    [uwsgi]
    socket = 127.0.0.1:8080
    callable = app
    wsgi-file = views.py
    threads = 1
    chmod-socket = 660
    thunder-lock = true
    master = true
    strict = true
    enable-threads = true
    vacuum = true
    single-interpreter = true
    die-on-term = true
    need-app = true
    disable-write-exception=true
    harakiri = 120
    max-requests =1000
    max-worker-lifetime = 3600
    reload-on-rss = 2048
    worker-reload-mercy = 60
    cheaper-algo = busyness
    processes = 20
    cheaper = 8
    cheaper-initial = 16
    cheaper-overload = 1
    cheaper-step = 16
    cheaper-busyness-multiplier = 30
    cheaper-busyness-min = 20
    cheaper-busyness-max = 70
    cheaper-busyness-backlog-alert = 16
    cheaper-busyness-backlog-step = 2


so how to fix this and what am I doing wrong

0 Ответов