8
5

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.

herokuでsidekiq起動時のエラー対処方法

Posted at

railsでsidekiqを使って非同期の処理を扱いたいherokuに乗っているアプリにworker dynoを足してデプロイしました。

# config/sidekiq.yml
:verbose: true
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:concurrency: 2
:queues:
 - default
# Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -C config/sidekiq.yml

ProcfileでLaunchingのコマンドを足したので動くと思ってたんですがダメでした。
config/sidekiq.ymlが悪いのか、config/secrets.ymlでREDISTOGO_URLを受け取れてないのかいろいろ疑ったんですが、結局ログ見たらtmp/pidsディレクトリが無いというエラーが有りました。

つまりデプロイ時にtmpフォルダを作らないといけないのでProcfileを以下のように修正

# Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
- worker: bundle exec sidekiq -C config/sidekiq.yml
+ worker: mkdir -p tmp/pids && bundle exec sidekiq -C config/sidekiq.yml

とても単純なところなんですが気付くまでちょっと時間かかりました。

てゆうかtmpフォルダって無かったらheroku側で作ってくれないかな

8
5
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
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?