How to keep Django server running in Lightsail even after closing SSH console tab

0

I am hosting a Django application through Amazon Lightsail and I want the Django server to keep running while the Lightsail instance is running. To start the Django application server, I make the command "python manage.py runserver", and from then on, I can use my application in the browser. However, when I close the browser-based SSH client, the console stops running and so does my Django server. How can I make it so that my Django app continues to run even after closing the SSH client tab? Thank you.

Varun
質問済み 4ヶ月前298ビュー
1回答
3
承認された回答

Hello Varun,

To keep a Django server running on an Amazon Lightsail instance even after closing the SSH console tab, you typically need to use a process manager and potentially a tool for daemonizing the process.

The nohup command stands for "no hang up" and is used to run a command immune to hangups, with output to a non-tty. & at the end runs the command in the background.

nohup python manage.py runserver 0.0.0.0:8000 &

Please note that using nohup and & is a quick way to run a process in the background, but it's not a production-ready solution. For a production environment, you should consider using more robust process managers like Systemd and Supervisord, or deploying your Django application using application servers like Gunicorn or uWSGI behind a reverse proxy like Nginx or Apache.

Let me know if u need further assistance

Thanks

Abhinav

回答済み 4ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ