如何使用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