Skip to content

Commit 4b59a36

Browse files
author
Lennart Prelle
committed
cronjob to restart sidekiq workers daily, might help with the memoryoverflow
1 parent 6ef6241 commit 4b59a36

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

config/schedule.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
num_sidekiq_workers = 2
2+
rails_root = ENV['RAILS_ROOT'] || "/home/lprelle/diaspora"
3+
4+
every 1.day, :at => '1am' do
5+
num_sidekiq_workers.times do |num|
6+
command "kill -USR1 $(cat #{rails_root}/pids/sidekiq#{num}.pid)"
7+
end
8+
end
9+
10+
every 1.day, :at => '1:01 am' do
11+
num_sidekiq_workers.times do |num|
12+
command "kill -TERM $(cat #{rails_root}/pids/sidekiq#{num}.pid)"
13+
end
14+
end

script/diaspora.god

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ num_sidekiqworkers = 2
1515

1616
num_sidekiqworkers.times do |num|
1717
God.watch do |w|
18+
pid_file = File.join(rails_root, "pids/sidekiq#{num}.pid")
19+
1820
w.dir = "#{rails_root}"
1921
w.name = "sidekiq-#{num}"
2022
w.group = 'sidekiq'
2123
w.interval = 190.seconds
2224
w.env = {"QUEUE"=>"photos,receive_local,receive_salmon,receive,mail,socket_webfinger,delete_account,dispatch,http,http_service", "RAILS_ENV"=>rails_env}
23-
w.start = "bundle exec sidekiq"
25+
w.start = "bundle exec sidekiq -P #{pid_file}"
2426
w.log = "#{rails_root}/log/god.log"
2527

2628
#w.uid = 'lennart'

0 commit comments

Comments
 (0)