如何在后台运行 Django 项目

发布于 2025-01-20 23:57:59 字数 145 浏览 2 评论 0原文

最近我使用以下命令在终端上运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

红ご颜醉 2025-01-27 23:57:59

您可以运行nohup,如果您使用某些自动化软件,则不会设置命令的输出(在命令或执行的位置或执行)中不会创建的内容,

nohup python manage.py runserver 0.0.0.0:8000

以免崩溃部署,添加一个'&'在命令的末尾,这样

nohup python manage.py runserver 0.0.0.0:8000 &

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)

nohup python manage.py runserver 0.0.0.0:8000

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 python manage.py runserver 0.0.0.0:8000 &
扛起拖把扫天下 2025-01-27 23:57:59

您可以使用nohup命令,因此您的命令在没有终端的情况下运行,并且该程序中的所有输出将转到file nohup.out.out(在相同的目录中,您运行了命令)。

这样使用:

nohup python manage.py runserver 0.0.0.0:80

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
素罗衫 2025-01-27 23:57:59

您可以尝试:

python manage.py runserver 0.0.0.0:80 &

“&”关闭终端时,将执行的命令放在后台和设置init作为父进程中

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

绾颜 2025-01-27 23:57:59

您可以使用 screen 在后台运行程序。

这应该回答您的问题

You can use screen to run a program in background.

This should answer your question

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文