Merge pull request #1309 from stephankaag/sidetiq

Replace Clockwork with Sidetiq
This commit is contained in:
Sam 2013-08-14 16:51:04 -07:00
commit c2653b2915
44 changed files with 106 additions and 299 deletions

View File

@ -6,7 +6,7 @@
###
# This specifies how many of each task to run
concurrency: web=2,sidekiq=1,clockwork=1
concurrency: web=2,sidekiq=1
# Define the port range to use, must be in multiples of 1000
port: 3000

View File

@ -78,7 +78,7 @@ gem 'simple_handlebars_rails', path: 'vendor/gems/simple_handlebars_rails'
gem 'redcarpet', require: false
gem 'airbrake', '3.1.2', require: false # errbit is broken with 3.1.3 for now
gem 'clockwork', require: false
gem 'sidetiq', '>= 0.3.6'
gem 'eventmachine'
gem 'fast_xs'
gem 'fast_xor', git: 'https://github.com/CodeMonkeySteve/fast_xor.git'

View File

@ -144,15 +144,13 @@ GEM
bourne (1.4.0)
mocha (~> 0.13.2)
builder (3.0.4)
celluloid (0.13.0)
celluloid (0.14.1)
timers (>= 1.0.0)
certified (0.1.1)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
clockwork (0.5.0)
tzinfo (~> 0.3.35)
coderay (1.0.9)
connection_pool (1.0.0)
connection_pool (1.1.0)
daemons (1.1.9)
debug_inspector (0.0.2)
diff-lcs (1.2.4)
@ -213,6 +211,7 @@ GEM
hiredis (0.4.5)
httpauth (0.2.0)
i18n (0.6.4)
ice_cube (0.11.0)
image_optim (0.8.0)
fspath (~> 2.0.3)
image_size (~> 1.1.2)
@ -244,7 +243,7 @@ GEM
mocha (0.13.3)
metaclass (~> 0.0.1)
mock_redis (0.8.1)
multi_json (1.7.7)
multi_json (1.7.8)
multipart-post (1.2.0)
mustache (0.99.4)
net-scp (1.1.2)
@ -349,7 +348,7 @@ GEM
redis-activesupport (3.2.3)
activesupport (~> 3.2.3)
redis-store (~> 1.1.0)
redis-namespace (1.2.1)
redis-namespace (1.3.1)
redis (~> 3.0.0)
redis-rack (1.4.2)
rack (~> 1.4.1)
@ -401,17 +400,20 @@ GEM
shoulda-matchers (1.5.6)
activesupport (>= 3.0.0)
bourne (~> 1.3)
sidekiq (2.11.1)
celluloid (~> 0.13.0)
connection_pool (~> 1.0)
multi_json (~> 1)
redis (~> 3)
sidekiq (2.13.0)
celluloid (>= 0.14.1)
connection_pool (>= 1.0.0)
json
redis (>= 3.0)
redis-namespace
sidekiq-failures (0.1.0)
sidekiq (>= 2.2.1)
sinatra
slim
sprockets
sidetiq (0.3.6)
ice_cube (~> 0.11.0)
sidekiq (~> 2.13.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
@ -468,7 +470,6 @@ DEPENDENCIES
better_errors
binding_of_caller
certified
clockwork
diffy (>= 3.0)
discourse_emoji!
discourse_plugin!
@ -537,6 +538,7 @@ DEPENDENCIES
shoulda
sidekiq
sidekiq-failures
sidetiq (>= 0.3.6)
simple_handlebars_rails!
simplecov
sinatra

View File

@ -187,9 +187,6 @@ GEM
celluloid (0.14.1)
timers (>= 1.0.0)
certified (0.1.1)
clockwork (0.5.3)
activesupport (~> 4.0.0)
tzinfo (~> 0.3.35)
coderay (1.0.9)
connection_pool (1.1.0)
daemons (1.1.9)
@ -254,6 +251,7 @@ GEM
hiredis (0.4.5)
httpauth (0.2.0)
i18n (0.6.4)
ice_cube (0.11.0)
image_optim (0.8.1)
fspath (~> 2.0.3)
image_size (~> 1.1.2)
@ -370,7 +368,7 @@ GEM
ffi (>= 0.5.0)
redcarpet (3.0.0)
redis (3.0.4)
redis-namespace (1.3.0)
redis-namespace (1.3.1)
redis (~> 3.0.0)
redis-store (1.1.2)
redis (>= 2.2.0)
@ -419,6 +417,9 @@ GEM
redis-namespace
sidekiq-failures (0.2.1)
sidekiq (>= 2.2.1)
sidetiq (0.3.6)
ice_cube (~> 0.11.0)
sidekiq (~> 2.13.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
@ -481,7 +482,6 @@ DEPENDENCIES
better_errors
binding_of_caller
certified
clockwork
diffy (>= 3.0)
discourse_emoji!
discourse_plugin!
@ -550,6 +550,7 @@ DEPENDENCIES
shoulda
sidekiq
sidekiq-failures
sidetiq (>= 0.3.6)
simple_handlebars_rails!
simplecov
sinatra

View File

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

View File

@ -24,7 +24,7 @@ class AdminDashboardData
[ rails_env_check,
host_names_check,
gc_checks,
sidekiq_check || queue_size_check || clockwork_check,
sidekiq_check || queue_size_check,
ram_check,
facebook_config_check,
twitter_config_check,
@ -72,7 +72,7 @@ class AdminDashboardData
end
def self.recalculate_interval
# Could be configurable, but clockwork + multisite need to support it.
# Could be configurable, multisite need to support it.
30 # minutes
end
@ -93,10 +93,6 @@ class AdminDashboardData
I18n.t('dashboard.sidekiq_warning') if Jobs.queued > 0 and (last_job_performed_at.nil? or last_job_performed_at < 2.minutes.ago)
end
def clockwork_check
I18n.t('dashboard.clockwork_warning') unless Jobs::ClockworkHeartbeat.is_clockwork_running?
end
def queue_size_check
queue_size = Jobs.queued
I18n.t('dashboard.queue_size_warning', queue_size: queue_size) unless queue_size < 100

View File

@ -127,15 +127,6 @@ module Discourse
# So open id logs somewhere sane
config.after_initialize do
OpenID::Util.logger = Rails.logger
if ENV['EMBED_CLOCKWORK']
puts ">> Running clockwork in background thread"
require_relative "clock"
Thread.new do
Clockwork.run
end
end
end
end
end

View File

@ -1,39 +0,0 @@
require 'clockwork'
unless ENV['EMBED_CLOCKWORK']
require_relative 'boot'
require_relative 'environment'
end
# These are jobs you should run on a regular basis to make your
# forum work properly.
def setup_log
Clockwork.configure do |config|
config[:logger].close
config[:logger] = Logger.new(ENV["CLOCK_LOG"])
end if ENV["CLOCK_LOG"]
end
trap('HUP') { setup_log }
setup_log
module Clockwork
handler do |job|
# TODO: we need to rethink scheduling here, cancel scheduled jobs
# iterates through all jobs, that is massively inefficient
# Jobs.cancel_scheduled_job(job, all_sites: true)
#
# see: http://meta.discourse.org/t/auto-close-behaviour/8249/2
Jobs.enqueue(job, all_sites: true)
end
every(1.day, 'enqueue_digest_emails', at: '06:00')
every(1.day, 'category_stats', at: '04:00')
every(1.day, 'ensure_db_consistency', at: '02:00')
every(10.minutes, 'periodical_updates')
every(1.day, 'version_check')
every(1.minute, 'clockwork_heartbeat')
every(1.minute, 'poll_mailbox')
every(30.minutes, 'destroy_old_deletion_stubs')
every(AdminDashboardData.recalculate_interval.minutes, 'dashboard_stats')
end

View File

@ -68,26 +68,6 @@ end
after "deploy:setup", "config:nginx"
# Tasks to start/stop/restart a daemonized clockwork instance
namespace :clockwork do
desc "Start clockwork"
task :start, :roles => [:app] do
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"
end
task :stop, :roles => [:app] do
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"
end
task :restart, :roles => [:app] do
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"
end
end
after "deploy:stop", "clockwork:stop"
after "deploy:start", "clockwork:start"
before "deploy:restart", "clockwork:restart"
# Seed your database with the initial production image. Note that the production
# image assumes an empty, unmigrated database.
namespace :db do

View File

@ -95,23 +95,5 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
process.daemonize = true
end
# Perhaps you want to run `hostname -f` here? It depends on your environment
# In any case, ensure the output is what you expect it to be on the system
# running clockwork!
if `hostname -s`.strip == "host to run on"
app.process("clockwork") do |process|
pidfile = "#{rails_root}/tmp/pids/clockwork.pid"
process.start_command = "/usr/bin/env CLOCK_LOG=#{rails_root}/log/clockwork.log RAILS_ENV=#{rails_env} bundle exec clockwork config/clock.rb"
process.pid_file = pidfile
process.start_grace_time = 30.seconds
process.stop_grace_time = 10.seconds
process.restart_grace_time = 10.seconds
process.uid = user
process.gid = group
process.daemonize = true
end
end
end

View File

@ -1,6 +1,10 @@
sidekiq_redis = { url: $redis.url, namespace: 'sidekiq' }
Sidekiq.configure_server { |config| config.redis = sidekiq_redis }
Sidekiq.configure_server do |config|
config.redis = sidekiq_redis
Sidetiq::Clock.start!
end
Sidekiq.configure_client { |config| config.redis = sidekiq_redis }
Sidekiq.logger.level = Logger::WARN

View File

@ -419,7 +419,6 @@ cs:
rails_env_warning: "Váš server běží v módu %{env}."
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."
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>.'
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>.'
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>.'
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ů.'
memory_warning: 'Váš server má méně než 1 GB paměti. Doporučená konfigurace je alespoň 1 GB paměti.'

View File

@ -375,7 +375,6 @@ de:
rails_env_warning: "Dein Server läuft im %{env}-Modus."
host_names_warning: "Deine config/database.yml-Datei verwendet localhost als Hostname. Trage hier den Hostnamen deiner Webseite ein."
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>.'
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>.'
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>.'
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.'
memory_warning: 'Dein Server läuft mit weniger als 1 GB Hauptspeicher. Mindestens 1 GB Hauptspeicher werden empfohlen.'

View File

@ -388,7 +388,6 @@ en:
rails_env_warning: "Your server is running in %{env} mode."
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
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>.'
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>.'
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>.'
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.'
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'

View File

@ -386,7 +386,6 @@ fr:
rails_env_warning: "Votre serveur fonctionne dans l'environnement de %{env}."
host_names_warning: "Le fichier config/database.yml utilise le nom d'hôte par défaut. Veuillez renseigner votre nom d'hôte."
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>."
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>."
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>."
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."
memory_warning: "Votre serveur dispose de moins de 1 Go de mémoire vive. Au moins 1 Go de RAM est recommandé."

View File

@ -285,7 +285,6 @@ id:
rails_env_warning: "Your server is running in %{env} mode."
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
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>.'
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>.'
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>.'
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'

View File

@ -371,7 +371,6 @@ it:
rails_env_warning: "Il tuo server è in modalità %{env}."
host_names_warning: "Il tuo file config/database.yml sta usando l'hostname localhost di default. Aggiornalo con l'hostname del tuo sito."
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>.'
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>.'
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>."
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.'
memory_warning: 'Il tuo server ha meno di 1 GB di memoria. È raccomandato avere a disposizione almeno 1 GB di memoria.'

View File

@ -365,7 +365,6 @@ ko:
rails_env_warning: "Your server is running in %{env} mode."
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
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>.'
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>.'
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>.'
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.'
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'

View File

@ -391,7 +391,6 @@ nl:
rails_env_warning: "Je server draait in %{env} modus."
host_names_warning: "Het bestand config/database.yml heeft localhost als standaard hostname. Werk dat bij naar de hostname van je site."
gc_warning: 'Je server gebruikt de standaard ruby garbage collection instellingen, en daarmee krijg je niet de beste prestaties. Lees deze topic over instellingen voor prestaties: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
clockwork_warning: 'Clockwork draait niet. Zorg ervoor dat er altijd een clockwork process draait, zodat belanrijke taken kunnen worden gepland. <a href="https://github.com/tomykaira/clockwork">Hier is meer informatie over clockwork</a>.'
sidekiq_warning: 'Sidekiq draait niet. Veel taken, zoals het versturen van e-mails, worden asynchroon uitgevoerd door sidekiq. Zorg ervoor dat er altijd een sidekiq process draait. <a href="https://github.com/mperham/sidekiq">Hier is meer informatie over sidekiq</a>.'
queue_size_warning: "Het aantal taken in de wachtrij (%{queue_size}_ is best hoog. Dit kan duiden op problemen met het Sidekiq proces. Of je moet meer Sidekiq workers toevoegen."
memory_warning: 'Jouw server draait met minder dan 1 GB aan geheugen. Ten minste 1 GB geheugen is aanbevolen.'

View File

@ -403,9 +403,6 @@ pseudo:
ŵĥíčĥ ŵíłł ɳóť ǧíνé ýóů ťĥé ƀéšť ƿéřƒóřɱáɳčé. Řéáď ťĥíš ťóƿíč óɳ ƿéřƒóřɱáɳčé
ťůɳíɳǧ: <á ĥřéƒ="ĥťťƿ://ɱéťá.ďíščóůřšé.óřǧ/ť/ťůɳíɳǧ-řůƀý-áɳď-řáíłš-ƒóř-ďíščóůřšé/4126"
ťářǧéť="_ƀłáɳǩ">Ťůɳíɳǧ Řůƀý áɳď Řáíłš ƒóř Ďíščóůřšé</á>. ]]'
clockwork_warning: '[[ Čłóčǩŵóřǩ íš ɳóť řůɳɳíɳǧ. Éɳšůřé ťĥáť á čłóčǩŵóřǩ ƿřóčéšš
íš áłŵáýš řůɳɳíɳǧ šó ťĥáť íɱƿóřťáɳť ʲóƀš čáɳ ƀé ščĥéďůłéď. <á ĥřéƒ="ĥťťƿš://ǧíťĥůƀ.čóɱ/ťóɱýǩáířá/čłóčǩŵóřǩ"
ťářǧéť="_ƀłáɳǩ">Łéářɳ áƀóůť čłóčǩŵóřǩ ĥéřé</á>. ]]'
sidekiq_warning: '[[ Šíďéǩíƣ íš ɳóť řůɳɳíɳǧ. Ϻáɳý ťášǩš, łíǩé šéɳďíɳǧ éɱáíłš,
ářé éхéčůťéď ášýɳčĥřóɳóůšłý ƀý šíďéǩíƣ. Рłéášé éɳšůřé áť łéášť óɳé šíďéǩíƣ ƿřóčéšš
íš řůɳɳíɳǧ. <á ĥřéƒ="ĥťťƿš://ǧíťĥůƀ.čóɱ/ɱƿéřĥáɱ/šíďéǩíƣ" ťářǧéť="_ƀłáɳǩ">Łéářɳ

View File

@ -354,7 +354,6 @@ pt_BR:
rails_env_warning: "Seu servidor está rodando no modo %{env}."
host_names_warning: "O arquivo config/database.yml está usando hostname padrão localhost. Modifique para usar o hostname do seu site."
gc_warning: 'Seu servidor está rodando a coleta de lixo do ruby com os parâmetros padrão (default ruby garbage collection parameters), os quais não irão propiciar a melhor performance. Leia este tópico sobre ajuste de performance: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126" target="_blank">Tuning Ruby and Rails for Discourse</a>.'
clockwork_warning: 'Clockwork não está em execução. Certifique-se que o processo clockwork esteja sempre em execução para que tarefas importantes seja agendadas. <a href="https://github.com/tomykaira/clockwork" target="_blank">Aprenda sobre clockwork aqui</a>.'
sidekiq_warning: 'Sidekiq não está em execução. Muitas tarefas, como envio de emails, são executadas de forma assíncrona pelo sidekiq. Por favor certifique-se de que ao menos um processo sidekiq esteja execução. <a href="https://github.com/mperham/sidekiq" target="_blank">Aprenda sobre Sidekiq aqui</a>.'
queue_size_warning: 'O número de tarefas agendadas é %{queue_size}, o que é alto. Isto pode indicar um problema com o(s) processo(s) Sidekiq, ou você pode estar precisando de mais Sidekiq workers.'
memory_warning: 'Seu servidor está rodando com menos de 1 GB de memória total. Pelo menos 1 GB é quantidade de memória recomendada.'

View File

@ -451,7 +451,6 @@ ru:
rails_env_warning: 'Ваш сервер работает в режиме %{env}.'
host_names_warning: Ваш файл config/database.yml использует локальное имя хоста по умолчанию. Поменяйте его на имя хоста вашего сайта.
gc_warning: 'Ваш сервер использует параметры ruby garbage collection по умолчанию, что ведет не к лучшей производительности. Прочитайте эту тему про настройку производительности: <a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>.'
clockwork_warning: 'Clockwork не запущен. Убедитесь, что процесс clockwork всегда работает, чтобы распланировать выполнение важных задач. <a href="https://github.com/tomykaira/clockwork">Узнайте больше о clockwork здесь</a>.'
sidekiq_warning: 'Sidekiq не запущен. Сейчас многие задачи, такие как отправка электронных писем, выполняются асинхронно. Пожалуйста, убедитесь, что хотя бы один процесс sidekiq запущен. <a href="https://github.com/mperham/sidekiq">Узнайте больше о Sidekiq здесь</a>.'
queue_size_warning: 'Количество задач в очереди достигло большого размера %{queue_size}. Это может привести к проблемам с процессом(ами) Sidekiq, или вам придется добавить больше Sidekiq workers.'
memory_warning: Общее количество памяти, используемое вашим сервером, составляет менее 1 GB. Рекомендовано использовать минимум 1 GB.

View File

@ -307,7 +307,6 @@ sv:
rails_env_warning: "Your server is running in %{env} mode."
host_names_warning: "Your config/database.yml file is using the default localhost hostname. Update it to use your site's hostname."
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>.'
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>.'
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>.'
memory_warning: 'Your server is running with less than 1 GB of total memory. At least 1 GB of memory is recommended.'
facebook_config_warning: 'The server is configured to allow signup and log in with Facebook (enable_facebook_logins), but the app id and app secret values are not set. Go to <a href="/admin/site_settings">the Site Settings</a> and update the settings. <a href="https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide#enable-facebook-logins" target="_blank">See this guide to learn more</a>.'

View File

@ -378,7 +378,6 @@ zh_CN:
rails_env_warning: "你的服务器运行在 %{env} 模式。"
host_names_warning: "你的 config/database.yml 文件使用的是缺省的 localhost 主机名。请更改成你的站点主机名。"
gc_warning: '你的服务器使用的是缺省的 ruby 垃圾回收参数,这个配置无法提供最高性能。请阅读此性能调优文档:<a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>。'
clockwork_warning: '发条装置Clockwork并未运行。请确保运行一个 clockwork 进程,这样一些重要的工作能够被安排执行。<a href="https://github.com/tomykaira/clockwork">了解发条装置clockwork</a>。'
sidekiq_warning: 'Sidekiq 不在运行。很多任务,例如发送电子邮件,是异步的被 sidekiq 调度执行的。请确保至少运行一个 sidekiq 进程。<a href="https://github.com/mperham/sidekiq">了解 Sidekiq</a>。'
queue_size_warning: '队列中的任务数为%{queue_size}任务较多。这可能因为Sidekiq进程出问题导致或者需要更多的Sidekiq进程。'
memory_warning: '你的服务器环境内存少于 1GB我们建议至少要有 1GB 内存'

View File

@ -371,7 +371,6 @@ zh_TW:
rails_env_warning: "你的服務器運行在 %{env} 模式。"
host_names_warning: "你的 config/database.yml 文件使用的是缺省的 localhost 主機名。請更改成你的站點主機名。"
gc_warning: '你的服務器使用的是缺省的 ruby 垃圾回收參數,這個配置無法提供最高性能。請閱讀此性能調優文檔:<a href="http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126">Tuning Ruby and Rails for Discourse</a>。'
clockwork_warning: '發條裝置Clockwork並未運行。請確保運行一個 clockwork 進程,這樣一些重要的工作能夠被安排執行。<a href="https://github.com/tomykaira/clockwork">了解發條裝置clockwork</a>。'
sidekiq_warning: 'Sidekiq 不在運行。很多任務,例如發送電子郵件,是異步的被 sidekiq 調度執行的。請確保至少運行一個 sidekiq 進程。<a href="https://github.com/mperham/sidekiq">了解 Sidekiq</a>。'
queue_size_warning: '隊列中的任務數爲%{queue_size}任務較多。這可能因爲Sidekiq進程出問題導致或者需要更多的Sidekiq進程。'
memory_warning: '你的服務器環境內存少于 1GB我們建議至少要有 1GB 內存'

View File

@ -10,12 +10,6 @@ missingok
create 0644
/home/discourse/discourse/log/clockwork.log
{
postrotate
pkill -HUP -f clockwork
endscript
}
/home/discourse/discourse/log/sidekiq.log
{
# Should we just kill sidekiq?

View File

@ -1,4 +1,5 @@
require 'sidekiq/web'
require 'sidetiq/web'
require_dependency 'admin_constraint'
require_dependency 'staff_constraint'

View File

@ -53,23 +53,19 @@ For details on how to reduce the monthly cost of your application, see [Advanced
heroku config:get OPENREDIS_URL
heroku config:set REDIS_PROVIDER_URL=<result of above command>
4. Add the [Heroku Scheduler](https://addons.heroku.com/scheduler) add-on, this saves us from running a separate clock process, reducing the cost of the app.
heroku addons:add scheduler:standard
5. Run bundler
4. Run bundler
bundle install
6. Generate a secret token in the terminal.
5. Generate a secret token in the terminal.
rake secret
7. Push the secret to the stored heroku environment variables, this will now be available to your app globally.
6. Push the secret to the stored heroku environment variables, this will now be available to your app globally.
heroku config:add SECRET_TOKEN=<generated secret>
8. Precompile assets.
. Precompile assets.
There are two options for precompilation. Either precompile locally, **before each deploy** or enable [Heroku's experimental user-env-compile](https://devcenter.heroku.com/articles/labs-user-env-compile) feature and Heroku will precompile your assets for you.
@ -113,11 +109,11 @@ For details on how to reduce the monthly cost of your application, see [Advanced
git add public/assets
git push heroku heroku:master
9. Push your heroku branch to Heroku.
8. Push your heroku branch to Heroku.
git push heroku heroku:master
10. Migrate and seed the database.
9. Migrate and seed the database.
heroku run rake db:migrate db:seed_fu
@ -148,27 +144,9 @@ For details on how to reduce the monthly cost of your application, see [Advanced
SiteSetting.create(:name => 'force_hostname', :data_type =>1, :value=>'yourappnamehere.herokuapp.com')
```
5. Provision the Heroku Scheduler.
5. Start Sidekiq.
This will allow Heroku Scheduler to cue up tasks rather than running a separate clock process.
In the [Heroku dashboard](https://dashboard.heroku.com/apps), select your app, then click on **Heroku Scheduler Standard** under your Add-ons.
Next, add a Job for each of the following:
TASK FREQUENCY NEXT RUN
------------------------------------------------------
rake enqueue_digest_emails Daily 06:00
rake category_stats Daily 04:00
rake periodical_updates Every 10 minutes --:--
rake version_check Daily 01:00
6. Start Sidekiq.
In the [Heroku dashboard](https://dashboard.heroku.com/apps), select your app and you will see the separate processes that have been created for your application under Resources. You will only need to start the sidekiq process for your application to run properly. The clock process is covered by Heroku Scheduler, and you can even remove this from the Procfile before deploying if you so wish. The worker process has been generated as a Rails default and can be ignored. As you can see **the Sidekiq process costs $34 monthly** to run. If you want to reduce this cost, check out [Advanced Heroku deployment](#advanced-heroku-deployment).
In the [Heroku dashboard](https://dashboard.heroku.com/apps), select your app and you will see the separate processes that have been created for your application under Resources. You will only need to start the sidekiq process for your application to run properly. The worker process has been generated as a Rails default and can be ignored. As you can see **the Sidekiq process costs $34 monthly** to run. If you want to reduce this cost, check out [Advanced Heroku deployment](#advanced-heroku-deployment).
Click on the check-box next to the Sidekiq process and click Apply Changes

View File

@ -185,7 +185,6 @@ Edit /var/www/discourse/config/discourse.pill
- change application name from 'discourse' if necessary
- Ensure appropriate Bluepill.application line is uncommented
- search for "host to run on" and change to current hostname
- note: clockwork should run on only one host
Edit /var/www/discourse/config/initializers/secret_token.rb

View File

@ -34,12 +34,11 @@ Alternately, you can try the [unofficial Heroku install guide][2], or the [BitNa
- Prepackage all assets using rake
- Run the Rails database migrations
- Run a sidekiq process for background jobs
- Run a clockwork process for enqueing scheduled jobs
- Run several Rails processes, preferably behind a proxy like Nginx.
### Low memory (less than 2 GB)
Remember you *will* need swap enabled (enough for a total of 4 GB, so 2 GB swap with 2 GB RAM, and 3 GB swap with 1 GB ram, etc) and working! To reduce memory footprint, clockwork can run inside your web server. If you launch the your web server with `EMBED_CLOCKWORK=1`, clockwork will run in a backgroud thread. As clockwork itself only performs scheduling, it will have very little impact on performance.
Remember you *will* need swap enabled (enough for a total of 4 GB, so 2 GB swap with 2 GB RAM, and 3 GB swap with 1 GB ram, etc) and working!
[1]: https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md
[2]: https://github.com/discourse/discourse/blob/master/docs/HEROKU.md

View File

@ -22,8 +22,6 @@ On old server, run `git status` and review changes to the tree. For example:
#
# app/views/layouts/application.html.erb.bitnami
# config/environments/production.rb
# log/clockworkd.clock.output
# log/clockworkd.clock.pid
# log/sidekiq.pid
# vendor/gems/active_model_serializers/
# vendor/gems/fast_blank/

View File

@ -43,4 +43,4 @@ Discourse extends the built-in Rails CSRF protection in the following ways:
### Deployment concerns
We strongly recommend that the various Discourse processes (web server, clockwork, sidekiq) run under a non-elevated account. See [our install guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md) for details.
We strongly recommend that the various Discourse processes (web server, sidekiq) run under a non-elevated account. See [our install guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md) for details.

View File

@ -34,8 +34,8 @@ module Jobs
raise "Overwrite me!"
end
def perform(opts={})
opts = opts.with_indifferent_access
def perform(*args)
opts = args.extract_options!.with_indifferent_access
if SiteSetting.queue_jobs?
Sidekiq.redis do |r|
@ -75,10 +75,12 @@ module Jobs
end
def self.enqueue(job_name, opts={})
class Scheduled < Base
include Sidetiq::Schedulable
end
klass_name = "Jobs::#{job_name.to_s.camelcase}"
klass = klass_name.constantize
def self.enqueue(job_name, opts={})
klass = "Jobs::#{job_name.to_s.camelcase}".constantize
# Unless we want to work on all sites
unless opts.delete(:all_sites)
@ -90,7 +92,7 @@ module Jobs
if opts[:delay_for].present?
klass.delay_for(opts.delete(:delay_for)).delayed_perform(opts)
else
Sidekiq::Client.enqueue(klass_name.constantize, opts)
Sidekiq::Client.enqueue(klass, opts)
end
else
# Otherwise execute the job right away

View File

@ -1,6 +1,7 @@
module Jobs
class CategoryStats < Jobs::Base
class CategoryStats < Jobs::Scheduled
recurrence { daily.hour_of_day(4) }
def execute(args)
Category.update_stats

View File

@ -1,33 +0,0 @@
module Jobs
class ClockworkHeartbeat < Jobs::Base
sidekiq_options retry: false
def execute(args)
$redis.set last_heartbeat_at_key, Time.now.to_i
end
def self.is_clockwork_running?
if time = ClockworkHeartbeat.new.last_heartbeat_at
time > 2.minutes.ago
else
false
end
end
def last_heartbeat_at
if time_int = $redis.get(last_heartbeat_at_key)
Time.at(time_int.to_i)
else
nil
end
end
private
def last_heartbeat_at_key
'clockwork:last_heartbeat_at'
end
end
end

View File

@ -1,5 +1,6 @@
module Jobs
class DashboardStats < Jobs::Base
class DashboardStats < Jobs::Scheduled
recurrence { minutely(AdminDashboardData.recalculate_interval.minutes) }
def execute(args)
stats_json = AdminDashboardData.fetch_stats.as_json

View File

@ -1,6 +1,8 @@
module Jobs
# various consistency checks
class DestroyOldDeletionStubs < Jobs::Base
class DestroyOldDeletionStubs < Jobs::Scheduled
recurrence { hourly.minute_of_hour(0, 30) }
def execute(args)
PostDestroyer.destroy_stubs
end

View File

@ -1,7 +1,8 @@
module Jobs
# A daily job that will enqueue digest emails to be sent to users
class EnqueueDigestEmails < Jobs::Base
class EnqueueDigestEmails < Jobs::Scheduled
recurrence { daily.hour_of_day(6) }
def execute(args)
target_users.each do |u|

View File

@ -1,6 +1,8 @@
module Jobs
# various consistency checks
class EnsureDbConsistency < Jobs::Base
class EnsureDbConsistency < Jobs::Scheduled
recurrence { daily.hour_of_day(2) }
def execute(args)
TopicUser.ensure_consistency!
UserVisit.ensure_consistency!

View File

@ -4,7 +4,8 @@ module Jobs
# This job will run on a regular basis to update statistics and denormalized data.
# If it does not run, the site will not function properly.
class PeriodicalUpdates < Jobs::Base
class PeriodicalUpdates < Jobs::Scheduled
recurrence { hourly.minute_of_hour(0, 10, 20, 30, 40, 50) }
def execute(args)

View File

@ -5,8 +5,8 @@ require 'net/pop'
require_dependency 'email/receiver'
module Jobs
class PollMailbox < Jobs::Base
class PollMailbox < Jobs::Scheduled
recurrence { minutely }
sidekiq_options retry: false
def execute(args)

View File

@ -2,7 +2,8 @@ require_dependency 'discourse_hub'
require_dependency 'discourse_updates'
module Jobs
class VersionCheck < Jobs::Base
class VersionCheck < Jobs::Scheduled
recurrence { daily }
def execute(args)
if SiteSetting.version_checks? and (DiscourseUpdates.updated_at.nil? or DiscourseUpdates.updated_at < 1.minute.ago)

View File

@ -1,26 +0,0 @@
require 'spec_helper'
require 'jobs'
describe Jobs::ClockworkHeartbeat do
describe '#is_clockwork_running?' do
subject { Jobs::ClockworkHeartbeat.is_clockwork_running? }
it 'returns false if last_heartbeat_at is nil' do
Jobs::ClockworkHeartbeat.any_instance.stubs(:last_heartbeat_at).returns(nil)
subject.should be_false
end
it 'returns false if last_heartbeat_at is more than 2 minutes ago' do
Jobs::ClockworkHeartbeat.any_instance.stubs(:last_heartbeat_at).returns(10.minutes.ago)
subject.should be_false
end
it 'returns true if last_heartbeat_at is more recent than 2 minutes ago' do
Jobs::ClockworkHeartbeat.any_instance.stubs(:last_heartbeat_at).returns(Time.zone.now)
subject.should be_true
end
end
end

View File

@ -54,20 +54,6 @@ describe AdminDashboardData do
end
end
describe 'clockwork_check' do
subject { AdminDashboardData.new.clockwork_check }
it 'returns nil when clockwork is running' do
Jobs::ClockworkHeartbeat.stubs(:is_clockwork_running?).returns(true)
subject.should be_nil
end
it 'returns a string when clockwork is not running' do
Jobs::ClockworkHeartbeat.stubs(:is_clockwork_running?).returns(false)
subject.should_not be_nil
end
end
describe 'sidekiq_check' do
subject { AdminDashboardData.new.sidekiq_check }