How do I keep my Django server running even after I close my ssh session?

后端 未结 3 1813
遥遥无期
遥遥无期 2021-01-30 18:02

I figured out how to run my Django application via sudo python /home/david/myproject/manage.py runserver 68.164.125.221:80. However, after I quit terminal, the serv

3条回答
  •  天命终不由人
    2021-01-30 18:28

    Use screen to create a new virtual window, and run the server there.

    $ screen
    $ python manage.py runserver
    

    You will see that Django server has started running.

    Now press Ctrl+A and then press the D key to detach from that screen. It will say:

    $ [detached from ###.pts-0.hostname]
    

    You can now safely logout from your terminal, log back in to your terminal, do other bits of coding in other directories, go for a vacation, do whatever you want.


    To return to the screen that you have detached from,

    $ screen -r
    

    To kill the django server now, simply press Ctrl+C like you would've done normally.


    To terminate this current screen instead of detaching from this screen, use Ctrl+D. It will say:

    $ [screen is terminating]
    $
    

提交回复
热议问题