django - 如何使用 Upstart ?

标签 django linux upstart

我有一个要部署的 Django 应用程序。我想使用 upstart 来运行该应用程序。

到目前为止,我已经将 upstart.conf 文件添加到/etc/init

并尝试使用

运行它
start upstart

但我得到的只是

start: Rejected send message, 1 matched rules; type="method_call", sender=":1.90" (uid=1000 pid=5873 comm="start upstart ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

.conf 文件的内容是:

# my upstart django script
# this script will start/stop my django development server
# optional stuff
description "start and stop the django development server"
version "1.0"
author "Calum"


# configuration variables.
# You'll want to change thse as needed
env DJANGO_HOME=/home/django/django-nexus7/nexus7
env DJANGO_PORT=8000
env DJANGO_HOST=0.0.0.0 # bind to all interfaces

# tell upstart we're creating a daemon
# upstart manages PID creation for you.
#expect fork

pre-start script
chdir $DJANGO_HOME
exec /usr/bin/python rm sqlite3.db
exec /usr/bin/python manage.py syncdb
exec /usr/bin/python manage.py loaddata fixtures/data.json
emit django_starting
end script

script
# My startup script, plain old shell scripting here.
chdir $DJANGO_HOME
exec /usr/bin/python manage.py run_gunicorn -c config/gunicorn
#exec /usr/bin/python manage.py runserver $DJANGO_HOST:$DJANGO_PORT &
# create a custom event in case we want to chain later
emit django_running
end script

我也曾尝试使用更简单的 .conf 文件,但或多或​​少遇到了相同的错误。 如果有人能告诉我我做错了什么,我将不胜感激

最佳答案

Upstart 作业只能由 root 启动,如果您尝试以普通用户身份启动一个作业,则会出现该错误。试试这个:

sudo start upstart

关于django - 如何使用 Upstart ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14595390/

相关文章:

linux - GtkWarning 无法打开显示 - 我如何从我的守护进程通知发送

bash - 如何在 Upstart 脚本中计算变量并使用它?

python - 如何使用 django rest 框架序列化一个带有直通模型的 ManyToManyField

c - 将数据包从一台linux服务器发送到另一台服务器(LINUX)

c - 如何为 Glade 的 GTK 按钮分配命令?

node.js - Node : 100s of simultaneous requests slows down server substantially. 操作系统问题?

python - 奇怪的 OpenCV .read() 挂起没有错误

python - 如何减少 Django 在查询子模型属性时调用数据库的次数?

python - Django - 使用电子邮件或用户名登录不起作用

python - 如何格式化从字典转换的Dataframe