【问题标题】:How to run Django project in backgroundHow to run Django project in background
【发布时间】:2022-11-09 11:28:06
【问题描述】:

Recent I am running Django project on terminal using this command:

python manage.py runserver 0.0.0.0:80

But Server is stopped by closing terminal, So I need to run server in background. How can I solve this issue?

  • Are you using this command for production ?
  • Minimize terminal?
  • When developing, why don't you want the terminal? It's content is useful for debugging. In production, you ought not to be using the development server.

标签: python django server


【解决方案1】:

You may try:

python manage.py runserver 0.0.0.0:80 &

"&" puts the executed command in background and sets init as it's parent process when you close the terminal

    【解决方案2】:

    You can use the nohup command, so your command runs without the terminal and all the outputs from the program will go to the file nohup.out (in the same directory you ran the command).

    Use like so:

    nohup python manage.py runserver 0.0.0.0:80
    
    • thank you. I have to install any package for nohup in terminal?
    • It is likely preinstalled, flag as an answer if it did work out for you! :)
    • this is not working
    【解决方案3】:

    You can use screen to run a program in background.

    This should answer your question

      猜你喜欢
      • 2022-12-02
      • 2022-12-27
      • 2022-12-19
      • 2022-12-19
      • 2022-12-28
      • 2022-12-26
      • 2022-12-28
      • 2022-12-02
      • 2022-12-26
      相关资源
      最近更新 更多