2

I am using Flask to create a web service. I hope to restart it like every 30 minutes. Is that possible to do that and how can it be realized?

Meanwhile, I tried to use subprocess (popen) to start the flask web service, terminate it and start it again, but the server could not be shut down unless the whole program, where I call subprocess, is also down.

I would very appreciate if you could share your knowledge and experience regarding to this issue.

4
  • 2
    What do you actually want to do? Why do you want to restart it every 30 minutes? You could add a cronjob to handle this, but it sounds like you're doing something you don't need to do. Commented Jul 26, 2016 at 0:28
  • Some useful info here: stackoverflow.com/questions/6337119/… Commented Jul 26, 2016 at 0:34
  • I am using the web service to call an API where the login info seems to be expired in 30 minutes. After I manually shut the web service down and start it again, it works well as I want. It seems like cronjob is a promising solution, I will try it out. Commented Jul 26, 2016 at 0:55
  • Finally, I managed to use Popen to have flask as a subprocess, terminate it and restart it without any problem. The trick part is how to kill the flask cleanly. Commented Jul 28, 2016 at 18:47

1 Answer 1

3

Flask web server is not supposed to serve production traffic. You should consider using some other service on top of WSGI protocol, such as gunicorn or uwsgi or apache mod_wsgi.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.