shell脚本重新启动屏幕内的django runserver
问题描述:
如何使用shell脚本重新启动django runserver?我在屏幕上运行了django服务器。shell脚本重新启动屏幕内的django runserver
这是我的shell脚本restartpython.sh:
killall -9 python
screen -r
sleep 5
exec python manage.py runserver 0.0.0.0:8000
ctrl+a d # how to make this into shell script??
当我执行这个脚本,我进入屏幕和蟒蛇服务器被杀害。但剧本没有跑这条线:
exec python manage.py runserver 0.0.0.0:8000
它显示了这个错误:
python: can't open file 'manage.py': [Errno 2] No such file or directory
此外,如何运行CTRL +(从屏幕退出)在shell脚本中的d?谢谢。
这听起来像是一个黑客一起伪生产配置。 ['runserver'不能用于生产](https://docs.djangoproject.com/en/1.10/ref/django-admin/#runserver)。你想做什么? – Chris
@Chris我试图做一个脚本来重新启动django runserver。因为,Django runserver有时会卡住。我现在仍处于开发阶段。我会用其他方法来制作。 – Krisnadi
通常我只是运行'python manage.py'并让它在一个开放的终端窗口中运行。有没有什么特别的原因可以通过在屏幕上添加'screen'和一个自定义的shell脚本来使事情复杂化? (请注意,'killall -9 python'几乎肯定不是应该在那里的东西,而且你可能不需要'exec'或者......) – Chris