■
■Scheduler、woker起動
deployタスク内に下記タスクを定義
desc "タスクの説明文" task :タスク名, roles: :app do run "(cd #{current_path} && QUEUE=* nohup bundle exec rake environment resque:work RAILS_ENV=#{rails_env} > /dev/null 2>&1 &) && sleep 1", :pty => true run "(cd #{current_path} && QUEUE=* nohup bundle exec rake environment resque:scheduler RAILS_ENV=#{rails_env} > /dev/null 2>&1 &) && sleep 1", :pty => true end
killのために、起動時にfileを作成して残しておく
作成
cd *** && pgrep -p 1 -f resque > pid_list.txt
読み込み&kill
cat pid_list.txt | xargs kill
■Redisのresqueデータの説明
redis−cliの接続コマンド
redis-cli -h サーバ名(IPでも) -p 6379
データ取得コマンド
keys * すべてのキーを取得
キーの説明
値の取得コマンドと値の例
1) "ElastiCacheMasterReplicationTimestamp" AWSElastiCacheのタイムスタンプ(resqueとは無関係) 2) "[namespace]:worker:[実行サーバIPアドレス]:8846:*" workerが起動されているサーバのIPとプロセスのPID、最後に実行したジョブとその時刻 コマンド:get "{\"queue\":\"batch\",\"run_at\":\"2015-02-07T14:25:00Z\",\"payload\":{\"class\":\"[クラス名]\",\"args\":}}" 3) "[namespace]:delayed:last_enqueued_at" ジョブが最後にキューに登録された時刻 コマンド:hvals 1) "2015-02-08 14:49:00 +0900" 4) "[namespace]:worker:[実行サーバIPアドレス]:8846:*:started" 最後にworker:[実行サーバIPアドレス]:8846でジョブが開始された時刻 コマンド:get "2015-02-07 23:12:15 +0900" 5) "Redis::Mutex:[ジョブ名]" 排他制御用のpage_view_counterのロック値 コマンド:get 1421322711.8214214 6) "[namespace]:workers" redisに接続しているワーカープロセスのサーバIPとプロセスのPID コマンド:smembers 1) "[サーバIPアドレス]:1234:*" 7) "[namespace]:queues" redisに登録されているキューの名前[namespace] コマンド:smembers 1) "[namespace]" 8) "[namespace]:schedules" スケジュールされているジョブ コマンド:hvals 1) "{\"description\":\"ジョブ説明\",\"queue\":\"[namespace]",\"class\":\"クラス名",\"cron\":\"cronスケジュール"}" 9) "[namespace]:[namespace]:resque_scheduler_master_lock" マスタースケジューラとして登録されているスケジューラプロセスのサーバ名とプロセスのPID コマンド:get サーバ名:20289 10) "[namespace]:queue:[キュー名]" [キュー名]に登録されているジョブ コマンド: llen key で、登録数を取得 lindex key indexで値を取得 {\"class\":\"クラス名",\"args\":}
ローカルであればresque-web -N namespace でweb画面で確認可能