2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RQをsystemdでデーモン化

Last updated at Posted at 2018-06-24

#RQをsystemdでデーモン化
分かる人には当たり前すぎるが、一部のわからない人のために寄稿(再投稿)

##環境
ubuntu 16.04LTS


Python クローリング&スクレイピングにてsupervisorでRQをデーモン化していたが

supervisorが上手く動かなかったためsystemdで実装

rq.service

[Unit]
Description = rq daemon

[Service]
WorkingDirectory=/home/pomcho555/project
Environment="PATH=/home/pomcho555/project/myprojectenv/bin"
ExecStart = /home/pomcho555/project/myprojectenv/bin/rq worker
Restart = always
Type = simple

[Install]
WantedBy = multi-user.target

注意点は3つ

  1. rq workerの本体の絶対パスを指定して実行してやること
  2. Environmentはpythonの実行環境を指定する、virtualenvを使っている場合はそのパス
  3. WorkingDirectoryを実行したいジョブ(sample_task.pyとか)と同じディレクトリにすること

2を怠るとrqは起動してもジョブが渡せない(違う階層にいる)ので注意

#実行
sudo systemctl start rq

#確認
sudo systemctl status rq

Active: active (running)がでたらOK

#おまけ
RQ用ダッシュボードモジュール
rq-dashboardは運用が捗るのでオススメ

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?