如何在后台运行 Django 项目
最近我使用以下命令在终端上运行 Django 项目:
python manage.py runserver 0.0.0.0:80
但是服务器通过关闭终端而停止,所以我需要在后台运行服务器。 我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以运行
nohup
,如果您使用某些自动化软件,则不会设置命令的输出(在命令或执行的位置或执行)中不会创建的内容,以免崩溃部署,添加一个'&'在命令的末尾,这样
You can run
nohup
, an output of the command will not be set what will not be created in the command (where or was executed)If you are using some automation software, in order not to crash the deployment, add an '&' at the end of the command, like this
您可以使用
nohup
命令,因此您的命令在没有终端的情况下运行,并且该程序中的所有输出将转到filenohup.out.out
(在相同的目录中,您运行了命令)。这样使用:
You can use the
nohup
command, so your command runs without the terminal and all the outputs from the program will go to the filenohup.out
(in the same directory you ran the command).Use like so:
您可以尝试:
“&”关闭终端时,将执行的命令放在后台和设置init作为父进程中
You may try:
"&" puts the executed command in background and sets init as it's parent process when you close the terminal
您可以使用 screen 在后台运行程序。
这应该回答您的问题
You can use screen to run a program in background.
This should answer your question