Replace Clockwork with Sidetiq

This commit is contained in:
Stephan Kaag 2013-08-07 19:25:05 +02:00
parent aec929b184
commit a6b4b5dbf2
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
sidekiq: bundle exec sidekiq -e $RAILS_ENV

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

@ -19,7 +19,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
# getting this to work was a nightmare
# bundle exec spawns a process totally messing with the demonize option
# so we suck the environment out and set it up first
# so we suck the environment out and set it up first
bootup_bundle = [ "#{ENV['HOME']}/.rvm/bin/rvm/bootup_bundle",
"/usr/local/rvm/bin/rvm/bootup_bundle",
`which bootup_bundle`.strip,
@ -68,7 +68,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
end
end
#debug instance
#debug instance
# app.process("thin-debug") do |process|
# 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"
# process.pid_file = "#{rails_root}/tmp/pids/thin-debug.pid"
@ -85,7 +85,7 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
app.process("sidekiq-worker") do |process|
pidfile = "#{rails_root}/tmp/pids/sidekiq-worker.pid"
process.start_command = "/usr/bin/env PIDFILE=#{pidfile} RAILS_ENV=#{rails_env} bundle exec sidekiq -L #{rails_root}/log/sidekiq.log"
process.start_command = "/usr/bin/env PIDFILE=#{pidfile} RAILS_ENV=#{rails_env} bundle exec sidekiq -L #{rails_root}/log/sidekiq.log"
process.pid_file = pidfile
process.start_grace_time = 30.seconds
process.stop_grace_time = 10.seconds
@ -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.
@ -101,7 +97,7 @@ For details on how to reduce the monthly cost of your application, see [Advanced
unset SECRET_TOKEN
When precompiling locally make sure to alter the .gitignore file to allow the public/assets folder into version control.
*.gitignore*
```diff
@ -110,14 +106,14 @@ For details on how to reduce the monthly cost of your application, see [Advanced
```
Also, you'll need to add a commit to get the precompiled assets onto Heroku.
git add public/assets
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
@ -142,33 +138,15 @@ For details on how to reduce the monthly cost of your application, see [Advanced
4. In Discourse admin settings, set `force_hostname` to your applications Heroku domain.
This step is required for Discourse to properly form links sent with account confirmation emails and password resets. The auto detected application url would point to an Amazon AWS instance.
Since you can't log in yet, you can set `force_hostname` in the console.
```ruby
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
@ -200,11 +178,11 @@ Create a .env file from the sample.
##### Use Rails console, with pry
foreman run rails console
##### Prepare the test database
foreman run rake db:test:prepare
##### Run tests
foreman run rake autospec
@ -257,8 +235,8 @@ You can now run basic load tests against your instalation. Here's an example que
heroku addons:add loaderio:test
loader.io is still in beta, so you mileage may vary, but the tests are free for now.
They currently require you verify your domain. A simple way to do this is to add a hard coded static route to `config.routes.rb` using the loaderio verification key. You'll see the key the first time you try to run a load test.
loader.io is still in beta, so you mileage may vary, but the tests are free for now.
They currently require you verify your domain. A simple way to do this is to add a hard coded static route to `config.routes.rb` using the loaderio verification key. You'll see the key the first time you try to run a load test.
*config/routes.rb*
@ -273,60 +251,60 @@ end
## Autoscaler
Adding the [Autoscaler Gem](https://github.com/JustinLove/autoscaler) can help you better manage the running cost of your application by scaling down the Sidekiq worker process when not in use. This could save up to $34 per month depending on your usage levels.
Adding the [Autoscaler Gem](https://github.com/JustinLove/autoscaler) can help you better manage the running cost of your application by scaling down the Sidekiq worker process when not in use. This could save up to $34 per month depending on your usage levels.
##### Whilst this Gem has the potential to save you money, it in no way guarantees it. Use of this Gem should be combined with careful monitoring of your applications processes and usage alerts where necessary.
1. Push your Heroku API key and app name to Heroku.
heroku config:add HEROKU_API_KEY=<get your API key from acct settings> HEROKU_APP=<your app name>
2. Add the Autoscaler Gem to the Gemfile.
*Gemfile*
```ruby
gem 'autoscaler', require: false
```
3. Modify the Sidekiq config file to use the Autoscaler middleware in production.
3. Modify the Sidekiq config file to use the Autoscaler middleware in production.
*config/initializers/sidekiq.rb*
```ruby
sidekiq_redis = { url: $redis.url, namespace: 'sidekiq' }
if Rails.env.production?
if Rails.env.production?
require 'autoscaler/sidekiq'
require 'autoscaler/heroku_scaler'
Sidekiq.configure_server do |config|
Sidekiq.configure_server do |config|
config.redis = sidekiq_redis
config.server_middleware do |chain|
chain.add(Autoscaler::Sidekiq::Server, Autoscaler::HerokuScaler.new('sidekiq'), 60)
end
end
Sidekiq.configure_client do |config|
Sidekiq.configure_client do |config|
config.redis = sidekiq_redis
config.client_middleware do |chain|
chain.add Autoscaler::Sidekiq::Client, 'default' => Autoscaler::HerokuScaler.new('sidekiq')
end
end
else
Sidekiq.configure_server { |config| config.redis = sidekiq_redis }
Sidekiq.configure_client { |config| config.redis = sidekiq_redis }
end
```
## S3 CDN
Heroku Cedar stack does not support Nginx as a caching layer, so you may want to host your static assets in a CDN so you're not hitting your rails app for every asset request.
This can be done simply using the [Asset Sync](https://github.com/rumblelabs/asset_sync) gem.
@ -336,7 +314,7 @@ You'll need an Amazon S3 account set up with a bucket configured with your app n
**Caveat:** This example relies on the app being deployed using the `heroku labs:enable user-env-compile` method detailed above. For instructions on manual compilation, please refer to the [Asset Sync](https://github.com/rumblelabs/asset_sync) gem readme.
1. Add the Asset Sync Gem to the Gemfile under assets.
*Gemfile*
```diff
@ -358,11 +336,11 @@ You'll need an Amazon S3 account set up with a bucket configured with your app n
3. Get the access keys that were created for the new user and push the S3 configs to Heroku.
heroku config:set FOG_PROVIDER=AWS AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=yyy FOG_DIRECTORY=appname-assets
4. Push the Gzip config setting to Heroku. This tells asset sync to upload Gzipped files where available.
heroku config:add ASSET_SYNC_GZIP_COMPRESSION=true
Now commit your changes to Git and push to Heroku.
If you open Chrome's Inspector, click on Network and refresh the page, your assets should now be showing an amazonaws.com url. Please refer to the [Asset Sync](https://github.com/rumblelabs/asset_sync) gem readme for more configuration options, or to use another CDN such as AWS CloudFront for better performance.
If you open Chrome's Inspector, click on Network and refresh the page, your assets should now be showing an amazonaws.com url. Please refer to the [Asset Sync](https://github.com/rumblelabs/asset_sync) gem readme for more configuration options, or to use another CDN such as AWS CloudFront for better performance.

View File

@ -50,7 +50,7 @@ Install necessary packages:
# Run these commands as your normal login (e.g. "michael")
sudo apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush python-software-properties
## Caching: Redis
## Caching: Redis
Redis is a networked, in memory key-value store cache. Without the Redis caching layer, we'd have to go to the database a lot more often for common information and the site would be slower as a result.
@ -140,10 +140,10 @@ Continue with Discourse installation
# Build and install ruby
rvm install 2.0.0
# Use installed ruby as default
rvm use 2.0.0 --default
# Install bundler
gem install bundler
@ -151,7 +151,7 @@ Continue with Discourse installation
git clone git://github.com/discourse/discourse.git /var/www/discourse
cd /var/www/discourse
git checkout master
# To run on the most recent numbered release instead of bleeding-edge:
#git checkout latest-release
@ -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
@ -216,7 +215,7 @@ Not english? Set the default language as appropriate:
# Not sure if your locale is supported? Check at the rails console:
LocaleSiteSetting.values
=> ["cs", "da", "de", "en", "es", "fr", "id", "it", "nb_NO", "nl", "pseudo", "pt", "ru", "sv", "zh_CN", "zh_TW"]
=> ["cs", "da", "de", "en", "es", "fr", "id", "it", "nb_NO", "nl", "pseudo", "pt", "ru", "sv", "zh_CN", "zh_TW"]
## nginx setup

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

@ -1,6 +1,6 @@
## Discourse Security
We take security very seriously at Discourse. We welcome any peer review of our 100% open source code to ensure nobody's Discourse forum is ever compromised or hacked.
We take security very seriously at Discourse. We welcome any peer review of our 100% open source code to ensure nobody's Discourse forum is ever compromised or hacked.
### Where should I report security issues?
@ -12,7 +12,7 @@ Discourse uses the PBKDF2 algorithm to encrypt salted passwords. This algorithm
**options you can customise in your production.rb file**
- `pbkdf2_algorithm`: the hashing algorithm used (default "sha256")
- `pbkdf2_algorithm`: the hashing algorithm used (default "sha256")
- `pbkdf2_iterations`: the number of iterations to run (default 64000)
### XSS
@ -25,7 +25,7 @@ There are 2 main scenarios we protect against:
2. **Markdown displayed on the page invokes an XSS.** To protect against client side preview XSS, Discourse uses [Google Caja](https://developers.google.com/caja/) in the preview window.
On the server side we run a whitelist based sanitizer, implemented using the [Sanitize gem](https://github.com/rgrove/sanitize). See the [relevant Discourse code](https://github.com/discourse/discourse/blob/master/lib/pretty_text.rb).
On the server side we run a whitelist based sanitizer, implemented using the [Sanitize gem](https://github.com/rgrove/sanitize). See the [relevant Discourse code](https://github.com/discourse/discourse/blob/master/lib/pretty_text.rb).
In addition, titles and all other places where non-admins can enter code are protected either using the Handlebars library or standard Rails XSS protection.
@ -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 }