Skip to content

Commit a6b4b5d

Browse files
committed
Replace Clockwork with Sidetiq
1 parent aec929b commit a6b4b5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+106
-299
lines changed

.procfile.sample

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
###
77

88
# This specifies how many of each task to run
9-
concurrency: web=2,sidekiq=1,clockwork=1
9+
concurrency: web=2,sidekiq=1
1010

1111
# Define the port range to use, must be in multiples of 1000
1212
port: 3000

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ gem 'simple_handlebars_rails', path: 'vendor/gems/simple_handlebars_rails'
7878

7979
gem 'redcarpet', require: false
8080
gem 'airbrake', '3.1.2', require: false # errbit is broken with 3.1.3 for now
81-
gem 'clockwork', require: false
81+
gem 'sidetiq', '>= 0.3.6'
8282
gem 'eventmachine'
8383
gem 'fast_xs'
8484
gem 'fast_xor', git: 'https://github.com/CodeMonkeySteve/fast_xor.git'

Gemfile.lock

+14-12
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,13 @@ GEM
144144
bourne (1.4.0)
145145
mocha (~> 0.13.2)
146146
builder (3.0.4)
147-
celluloid (0.13.0)
147+
celluloid (0.14.1)
148148
timers (>= 1.0.0)
149149
certified (0.1.1)
150150
childprocess (0.3.9)
151151
ffi (~> 1.0, >= 1.0.11)
152-
clockwork (0.5.0)
153-
tzinfo (~> 0.3.35)
154152
coderay (1.0.9)
155-
connection_pool (1.0.0)
153+
connection_pool (1.1.0)
156154
daemons (1.1.9)
157155
debug_inspector (0.0.2)
158156
diff-lcs (1.2.4)
@@ -213,6 +211,7 @@ GEM
213211
hiredis (0.4.5)
214212
httpauth (0.2.0)
215213
i18n (0.6.4)
214+
ice_cube (0.11.0)
216215
image_optim (0.8.0)
217216
fspath (~> 2.0.3)
218217
image_size (~> 1.1.2)
@@ -244,7 +243,7 @@ GEM
244243
mocha (0.13.3)
245244
metaclass (~> 0.0.1)
246245
mock_redis (0.8.1)
247-
multi_json (1.7.7)
246+
multi_json (1.7.8)
248247
multipart-post (1.2.0)
249248
mustache (0.99.4)
250249
net-scp (1.1.2)
@@ -349,7 +348,7 @@ GEM
349348
redis-activesupport (3.2.3)
350349
activesupport (~> 3.2.3)
351350
redis-store (~> 1.1.0)
352-
redis-namespace (1.2.1)
351+
redis-namespace (1.3.1)
353352
redis (~> 3.0.0)
354353
redis-rack (1.4.2)
355354
rack (~> 1.4.1)
@@ -401,17 +400,20 @@ GEM
401400
shoulda-matchers (1.5.6)
402401
activesupport (>= 3.0.0)
403402
bourne (~> 1.3)
404-
sidekiq (2.11.1)
405-
celluloid (~> 0.13.0)
406-
connection_pool (~> 1.0)
407-
multi_json (~> 1)
408-
redis (~> 3)
403+
sidekiq (2.13.0)
404+
celluloid (>= 0.14.1)
405+
connection_pool (>= 1.0.0)
406+
json
407+
redis (>= 3.0)
409408
redis-namespace
410409
sidekiq-failures (0.1.0)
411410
sidekiq (>= 2.2.1)
412411
sinatra
413412
slim
414413
sprockets
414+
sidetiq (0.3.6)
415+
ice_cube (~> 0.11.0)
416+
sidekiq (~> 2.13.0)
415417
simplecov (0.7.1)
416418
multi_json (~> 1.0)
417419
simplecov-html (~> 0.7.1)
@@ -468,7 +470,6 @@ DEPENDENCIES
468470
better_errors
469471
binding_of_caller
470472
certified
471-
clockwork
472473
diffy (>= 3.0)
473474
discourse_emoji!
474475
discourse_plugin!
@@ -537,6 +538,7 @@ DEPENDENCIES
537538
shoulda
538539
sidekiq
539540
sidekiq-failures
541+
sidetiq (>= 0.3.6)
540542
simple_handlebars_rails!
541543
simplecov
542544
sinatra

Gemfile_rails4.lock

+6-5
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ GEM
187187
celluloid (0.14.1)
188188
timers (>= 1.0.0)
189189
certified (0.1.1)
190-
clockwork (0.5.3)
191-
activesupport (~> 4.0.0)
192-
tzinfo (~> 0.3.35)
193190
coderay (1.0.9)
194191
connection_pool (1.1.0)
195192
daemons (1.1.9)
@@ -254,6 +251,7 @@ GEM
254251
hiredis (0.4.5)
255252
httpauth (0.2.0)
256253
i18n (0.6.4)
254+
ice_cube (0.11.0)
257255
image_optim (0.8.1)
258256
fspath (~> 2.0.3)
259257
image_size (~> 1.1.2)
@@ -370,7 +368,7 @@ GEM
370368
ffi (>= 0.5.0)
371369
redcarpet (3.0.0)
372370
redis (3.0.4)
373-
redis-namespace (1.3.0)
371+
redis-namespace (1.3.1)
374372
redis (~> 3.0.0)
375373
redis-store (1.1.2)
376374
redis (>= 2.2.0)
@@ -419,6 +417,9 @@ GEM
419417
redis-namespace
420418
sidekiq-failures (0.2.1)
421419
sidekiq (>= 2.2.1)
420+
sidetiq (0.3.6)
421+
ice_cube (~> 0.11.0)
422+
sidekiq (~> 2.13.0)
422423
simplecov (0.7.1)
423424
multi_json (~> 1.0)
424425
simplecov-html (~> 0.7.1)
@@ -481,7 +482,6 @@ DEPENDENCIES
481482
better_errors
482483
binding_of_caller
483484
certified
484-
clockwork
485485
diffy (>= 3.0)
486486
discourse_emoji!
487487
discourse_plugin!
@@ -550,6 +550,7 @@ DEPENDENCIES
550550
shoulda
551551
sidekiq
552552
sidekiq-failures
553+
sidetiq (>= 0.3.6)
553554
simple_handlebars_rails!
554555
simplecov
555556
sinatra

Procfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
web: bundle exec rails server -p $PORT
2-
sidekiq: bundle exec sidekiq -e $RAILS_ENV
3-
clockwork: bundle exec clockwork config/clock.rb
2+
sidekiq: bundle exec sidekiq -e $RAILS_ENV

app/models/admin_dashboard_data.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def problems
2424
[ rails_env_check,
2525
host_names_check,
2626
gc_checks,
27-
sidekiq_check || queue_size_check || clockwork_check,
27+
sidekiq_check || queue_size_check,
2828
ram_check,
2929
facebook_config_check,
3030
twitter_config_check,
@@ -72,7 +72,7 @@ def as_json
7272
end
7373

7474
def self.recalculate_interval
75-
# Could be configurable, but clockwork + multisite need to support it.
75+
# Could be configurable, multisite need to support it.
7676
30 # minutes
7777
end
7878

@@ -93,10 +93,6 @@ def sidekiq_check
9393
I18n.t('dashboard.sidekiq_warning') if Jobs.queued > 0 and (last_job_performed_at.nil? or last_job_performed_at < 2.minutes.ago)
9494
end
9595

96-
def clockwork_check
97-
I18n.t('dashboard.clockwork_warning') unless Jobs::ClockworkHeartbeat.is_clockwork_running?
98-
end
99-
10096
def queue_size_check
10197
queue_size = Jobs.queued
10298
I18n.t('dashboard.queue_size_warning', queue_size: queue_size) unless queue_size < 100

config/application.rb

-9
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ class Application < Rails::Application
127127
# So open id logs somewhere sane
128128
config.after_initialize do
129129
OpenID::Util.logger = Rails.logger
130-
131-
if ENV['EMBED_CLOCKWORK']
132-
puts ">> Running clockwork in background thread"
133-
require_relative "clock"
134-
135-
Thread.new do
136-
Clockwork.run
137-
end
138-
end
139130
end
140131
end
141132
end

config/clock.rb

-39
This file was deleted.

config/deploy.rb.sample

-20
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,6 @@ end
6868

6969
after "deploy:setup", "config:nginx"
7070

71-
# Tasks to start/stop/restart a daemonized clockwork instance
72-
namespace :clockwork do
73-
desc "Start clockwork"
74-
task :start, :roles => [:app] do
75-
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec clockworkd -c #{current_path}/config/clock.rb --pid-dir #{shared_path}/pids --log --log-dir #{shared_path}/log start"
76-
end
77-
78-
task :stop, :roles => [:app] do
79-
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec clockworkd -c #{current_path}/config/clock.rb --pid-dir #{shared_path}/pids --log --log-dir #{shared_path}/log stop"
80-
end
81-
82-
task :restart, :roles => [:app] do
83-
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec clockworkd -c #{current_path}/config/clock.rb --pid-dir #{shared_path}/pids --log --log-dir #{shared_path}/log restart"
84-
end
85-
end
86-
87-
after "deploy:stop", "clockwork:stop"
88-
after "deploy:start", "clockwork:start"
89-
before "deploy:restart", "clockwork:restart"
90-
9171
# Seed your database with the initial production image. Note that the production
9272
# image assumes an empty, unmigrated database.
9373
namespace :db do

config/discourse.pill.sample

+3-21
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
1919

2020
# getting this to work was a nightmare
2121
# bundle exec spawns a process totally messing with the demonize option
22-
# so we suck the environment out and set it up first
22+
# so we suck the environment out and set it up first
2323
bootup_bundle = [ "#{ENV['HOME']}/.rvm/bin/rvm/bootup_bundle",
2424
"/usr/local/rvm/bin/rvm/bootup_bundle",
2525
`which bootup_bundle`.strip,
@@ -68,7 +68,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
6868
end
6969
end
7070

71-
#debug instance
71+
#debug instance
7272
# app.process("thin-debug") do |process|
7373
# process.start_command = "bundle exec thin start -e development -t 0 -p 10040 -P #{rails_root}/tmp/pids/thin-debug.pid -l #{rails_root}/log/thin-debug.log" -d"
7474
# process.pid_file = "#{rails_root}/tmp/pids/thin-debug.pid"
@@ -85,7 +85,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
8585
app.process("sidekiq-worker") do |process|
8686
pidfile = "#{rails_root}/tmp/pids/sidekiq-worker.pid"
8787

88-
process.start_command = "/usr/bin/env PIDFILE=#{pidfile} RAILS_ENV=#{rails_env} bundle exec sidekiq -L #{rails_root}/log/sidekiq.log"
88+
process.start_command = "/usr/bin/env PIDFILE=#{pidfile} RAILS_ENV=#{rails_env} bundle exec sidekiq -L #{rails_root}/log/sidekiq.log"
8989
process.pid_file = pidfile
9090
process.start_grace_time = 30.seconds
9191
process.stop_grace_time = 10.seconds
@@ -95,23 +95,5 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
9595
process.daemonize = true
9696
end
9797

98-
# Perhaps you want to run `hostname -f` here? It depends on your environment
99-
# In any case, ensure the output is what you expect it to be on the system
100-
# running clockwork!
101-
if `hostname -s`.strip == "host to run on"
102-
app.process("clockwork") do |process|
103-
pidfile = "#{rails_root}/tmp/pids/clockwork.pid"
104-
105-
process.start_command = "/usr/bin/env CLOCK_LOG=#{rails_root}/log/clockwork.log RAILS_ENV=#{rails_env} bundle exec clockwork config/clock.rb"
106-
process.pid_file = pidfile
107-
process.start_grace_time = 30.seconds
108-
process.stop_grace_time = 10.seconds
109-
process.restart_grace_time = 10.seconds
110-
process.uid = user
111-
process.gid = group
112-
process.daemonize = true
113-
end
114-
end
115-
11698
end
11799

config/initializers/sidekiq.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
sidekiq_redis = { url: $redis.url, namespace: 'sidekiq' }
22

3-
Sidekiq.configure_server { |config| config.redis = sidekiq_redis }
3+
Sidekiq.configure_server do |config|
4+
config.redis = sidekiq_redis
5+
Sidetiq::Clock.start!
6+
end
7+
48
Sidekiq.configure_client { |config| config.redis = sidekiq_redis }
59

610
Sidekiq.logger.level = Logger::WARN

config/locales/server.cs.yml

-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ cs:
419419
rails_env_warning: "Váš server běží v módu %{env}."
420420
host_names_warning: "Vaše konfigurace v souboru config/database.yml používá 'localhost' jako jméno hostitele. Změňte toto nastavení na doménu vašeho webu."
421421
gc_warning: 'Váš server používá výchozí nastavení ruby garbage collectoru, což způsobuje snížený výkon. Přečtěte si toto téma ohledně ladění výkonu: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
422-
clockwork_warning: 'Clockwork neběží. Ujistěte se, že process clockwork vždy běží, aby mohly být plánovány důležité úlohy na pozadí. <a href="https://github.com/tomykaira/clockwork">Více informací o clockwork</a>.'
423422
sidekiq_warning: 'Sidekiq neběží. Řada úloh, jako je zasílání emailů, se provádí asynchronně na pozadí přes sidekiq. Prosím, ujistěte se, že alespoň jeden process sidekiq běží. <a href="https://github.com/mperham/sidekiq">Více o Sidekiq</a>.'
424423
queue_size_warning: 'Počet čekajících úloh je %{queue_size}, což je příliš mnoho. Mohlo by to indikovat problém se službou Sidekiq, nebo je zapotřebí spustit více Sidekiq worker procesů.'
425424
memory_warning: 'Váš server má méně než 1 GB paměti. Doporučená konfigurace je alespoň 1 GB paměti.'

config/locales/server.de.yml

-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ de:
375375
rails_env_warning: "Dein Server läuft im %{env}-Modus."
376376
host_names_warning: "Deine config/database.yml-Datei verwendet localhost als Hostname. Trage hier den Hostnamen deiner Webseite ein."
377377
gc_warning: 'Dein Server verwendet die Standardparameter für Rubys Garbage-Collector, die nicht optimal sind. Lese dieses Thema über Performanzeinstellungen (en): <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
378-
clockwork_warning: 'Clockwork läuft nicht. Stelle sicher, dass immer ein Clockwork-Prozess läuft, so dass wichtige Jobs eingeplant werden können. <a href="https://github.com/tomykaira/clockwork">Mehr über Clockwork erfährst du hier (en)</a>.'
379378
sidekiq_warning: 'Sidekiq läuft nicht. Viele Aufgaben, wie zum Beispiel das Versenden von Mails, werden asynchron durch Sidekiq ausgeführt. Stelle sicher, dass mindestens eine Sidekiq-Prozess läuft. <a href="https://github.com/mperham/sidekiq">Mehr über Sidekiq erfährst du hier (en)</a>.'
380379
queue_size_warning: 'Die Anzahl der Aktionen in der Warteschlange ist mit %{queue_size} ziemlich hoch. Das könnte auf ein Problem mit dem Sidekiq Prozess(en) hinweisen, oder du musst mehr Sidekiq Arbeiter hinzufügen.'
381380
memory_warning: 'Dein Server läuft mit weniger als 1 GB Hauptspeicher. Mindestens 1 GB Hauptspeicher werden empfohlen.'

config/locales/server.en.yml

-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ en:
388388
rails_env_warning: "Your server is running in %{env} mode."
389389
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
390390
gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126" target="_blank">Tuning Ruby and Rails for Discourse</a>.'
391-
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. <a href="https://github.com/tomykaira/clockwork" target="_blank">Learn about clockwork here</a>.'
392391
sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. <a href="https://github.com/mperham/sidekiq" target="_blank">Learn about Sidekiq here</a>.'
393392
queue_size_warning: 'The number of queued jobs is %{queue_size}, which is high. This could indicate a problem with the Sidekiq process(es), or you may need to add more Sidekiq workers.'
394393
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'

config/locales/server.fr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ fr:
386386
rails_env_warning: "Votre serveur fonctionne dans l'environnement de %{env}."
387387
host_names_warning: "Le fichier config/database.yml utilise le nom d'hôte par défaut. Veuillez renseigner votre nom d'hôte."
388388
gc_warning: "Votre serveur utilise les paramètres par défaut de collection du GC de ruby, ce qui ne vous donneras pas les meilleures performances. Merci de lire cette discussion sur <a href=\"http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126\">l'optimisation des performances de Ruby et Rails pour Discourse [EN]</a>."
389-
clockwork_warning: "Clockwork n'est pas lancé. Assurez-vous qu'un processus clockwork soit toujours lancé afin que les tâches importantes soient planifiées. <a href=\"https://github.com/tomykaira/clockwork\">En savoir plus sur clockwork [EN]</a>."
390389
sidekiq_warning: "Sidekiq n'est pas lancé. De nombreuses tâches, comme l'envoie d'e-mails, sont executées de manière asynchrome par sidekiq. Assurez-vous d'avoir au moins un processus sidekiq de lancé. <a href=\"https://github.com/mperham/sidekiq\">En savoir plus sur sidekiq [EN]</a>."
391390
queue_size_warning: "Il y a %{queue_size} tâches dans la file d'attente, ce qui est beaucoup. Cela peut provenir d'un problème avec les processus Sidekiq, ou à un manque de processus Sidekiq travailleurs."
392391
memory_warning: "Votre serveur dispose de moins de 1 Go de mémoire vive. Au moins 1 Go de RAM est recommandé."

config/locales/server.id.yml

-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ id:
285285
rails_env_warning: "Your server is running in %{env} mode."
286286
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
287287
gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
288-
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. <a href="https://github.com/tomykaira/clockwork">Learn about clockwork here</a>.'
289288
sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. <a href="https://github.com/mperham/sidekiq">Learn about Sidekiq here</a>.'
290289
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'
291290

config/locales/server.it.yml

-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ it:
371371
rails_env_warning: "Il tuo server è in modalità %{env}."
372372
host_names_warning: "Il tuo file config/database.yml sta usando l'hostname localhost di default. Aggiornalo con l'hostname del tuo sito."
373373
gc_warning: 'Il tuo server sta usando i parametri di garbage collection di default di ruby, che potrebbero non garantirti le migliori performance. Leggi questo topic sul tuning delle performance: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
374-
clockwork_warning: 'Clockwork non è in esecuzione. Assicurati che un processo clockwork sia sempre in esecuzione per far sì che task importanti possano essere messi in coda. <a href="https://github.com/tomykaira/clockwork">Leggi di più su clockwork qui</a>.'
375374
sidekiq_warning: "Sidekiq non è in esecuzione. Molti task, come l'invio di email, sono eseguiti in maniera asincrona da sidekiq. Perfavore assicurati che almeno un processo sidekiq sia in esecuzione. <a href=\"https://github.com/mperham/sidekiq\">Leggi di più su sidekiq qui</a>."
376375
queue_size_warning: 'Il numero di job in coda è %{queue_size}, che è alto. Questo indica un problema con i processi Sidekiq, oppure dovresti aggiungere altri Sidekiq worker.'
377376
memory_warning: 'Il tuo server ha meno di 1 GB di memoria. È raccomandato avere a disposizione almeno 1 GB di memoria.'

config/locales/server.ko.yml

-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ ko:
365365
rails_env_warning: "Your server is running in %{env} mode."
366366
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
367367
gc_warning: 'Your server is using default ruby garbage collection parameters, which will not give you the best performance. Read this topic on performance tuning: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
368-
clockwork_warning: 'Clockwork is not running. Ensure that a clockwork process is always running so that important jobs can be scheduled. <a href="https://github.com/tomykaira/clockwork">Learn about clockwork here</a>.'
369368
sidekiq_warning: 'Sidekiq is not running. Many tasks, like sending emails, are executed asynchronously by sidekiq. Please ensure at least one sidekiq process is running. <a href="https://github.com/mperham/sidekiq">Learn about Sidekiq here</a>.'
370369
queue_size_warning: 'The number of queued jobs is %{queue_size}, which is high. This could indicate a problem with the Sidekiq process(es), or you may need to add more Sidekiq workers.'
371370
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'

0 commit comments

Comments
 (0)