简体   繁体   中英

How do I update my flask API code deployed over uWSGI and Nginx on ubuntu?

I followed the guide to set up my api here: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04

It works great and I can now make queries against my api succesfully. My issue is that now I want to tweak my flask app/api to do slightly different things and add functionality but the API i am pinging seems to be the old one, despite having updated the flask .py file on the server from my ssh. I tried going through all the steps in the tutorial i got it working with in the hopes of refreshing which code it accesses but nothing seems to work. Some of these commands I tried are:

sudo nginx -t

sudo service nginx restart

How can i do this and ping the updated flask .py file?

As per nos's suggestion i tried:

restart myproject

But this gave the following error:

restart: Rejected send message, 1 matched rules; type="method_call", sender=":1.8" (uid=1000 pid=2596 comm="restart thonapi ") interface="com.ubuntu.Upstart0_6.Job" member="Restart" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")

You need to restart the service you created for this application. The docs you link to have a "Create an Upstart Script" section which I assume you have done. This runs your application like a service and you need to restart that service with the command:

restart myproject

(Or whichever name you gave instead of "myproject")

You are restarting Nginx but not uwsgi. Nginx is just a proxy server that is routing requests to wsgi app. when you change in config of Nginx then these commands would work. but when changes are in wsgi app you have to restart service of uwsgi.

You could restart service by following commands. It depends what init system service is using

If service uses systemd system.

sudo systemctl restart myproject

Else if it uses upstart script.

sudo restart myproject

If all fails you can use or if you don't know about the init system being used:

sudo service restart myproject

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM