使用supervisor启动rqworker会导致产生错误

时间:2018-01-02 19:10:34

标签: django supervisord python-rq django-rq

尝试按照README中的说明使用此命令启动rqworker:

python manage.py rqworker default

出于某种原因,它会显示ERROR (spawn error),状态显示为FATAL Exited too quickly (process log may have details)。日志没有任何错误信息(exit status 1; not expected)。

我的主管配置:

[program:rqworker]
user=ubuntu
directory=/var/www/project/
command=/var/www/project/venv/bin/python manage.py rqworker default > /var/log/project/rq.log
stopsignal=TERM
autorestart=true
autostart=true
numprocs=1

直接从ubuntu用户运行命令按预期工作。

1 个答案:

答案 0 :(得分:1)

我提交了一份关于如何在Ubuntu上进行设置的PR,这可能会对你有帮助。

https://github.com/W7PEA/django-rq/blob/4afc19ab9866882c1809f89f84066856c94d75c6/README.rst

在Ubuntu上部署 创建一个运行高,默认和低队列的rqworker服务。

# humanoid.rb class Humanoid attr_reader :bounding_box def initialize(x, y, z, w, h, move_speed = 5) @bounding_box = BoundingBox.new(x, y, z, w, h) @move_speed = move_speed end def draw if (needs_render?) Gosu.draw_rect(bounding_box.x, bounding_box.y, bounding_box.w, bounding_box.h, Gosu::Color::RED, bounding_box.z) end end def update if Gosu.button_down? Gosu::KB_LEFT or Gosu::button_down? Gosu::GP_LEFT move :left end if Gosu.button_down? Gosu::KB_RIGHT or Gosu::button_down? Gosu::GP_RIGHT move :right end if Gosu.button_down? Gosu::KB_UP or Gosu::button_down? Gosu::GP_BUTTON_0 move :up end if Gosu.button_down? Gosu::KB_DOWN or Gosu::button_down? Gosu::GP_BUTTON_1 move :down end end def needs_render? true end def move(direction) if direction == :left @bounding_box.x -= @move_speed elsif direction == :right @bounding_box.x += @move_speed elsif direction == :up @bounding_box.y -= @move_speed else @bounding_box.y += @move_speed end end end

sudo vi /etc/systemd/system/rqworker.service

启用并启动服务

[Unit] Description=Django-RQ Worker After=network.target [Service] WorkingDirectory=<<path_to_your_project_folder>> ExecStart=/home/ubuntu/.virtualenv/<<your_virtualenv>>/bin/python \ <<path_to_your_project_folder>>/manage.py \ rqworker high default low [Install] WantedBy=multi-user.target
sudo systemctl enbable rqworker