2017-09-04 5 views
1

Je rencontre des problèmes avec les travailleurs que j'ai mis en place pour un site Web. Voici quelques antécédents de l'application: Il fonctionne sur les rails 3.0.2, en utilisant mongodb, redis gem 2.2.2. Afin de garder les travailleurs en état de marche, j'ai mis en place la gemme de Dieu et de spécifier que 6 travailleurs devraient fonctionner dans l'environnement de production. Je vais coller le fichier resque.god.rb ci-dessous. En outre, il existe un serveur Ubuntu unique qui est configuré pour les services resque-workers et elasticsearch uniquement afin qu'il ne partage aucun autre service. Mon problème est que pour une raison quelconque, les travailleurs continuent de mourir et se connectent juste "*** Exiting ..." dans mon fichier log/resque-worker.log qui est extrêmement ennuyeux parce que je ne sais pas ce qui est passe. Il n'enregistre rien dans le fichier syslog, ni le dmesgResque travailleurs en train de mourir silencieusement

Ceci est un morceau de ce que je reçois dans le journal (pas utile pour moi)

*** Starting worker workers:19166:* 
*** Starting worker workers:19133:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Starting worker workers:19251:* 
*** Starting worker workers:19217:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Starting worker workers:19330:* 
*** Starting worker workers:19297:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 

Voici mon code resque.god.rb:

require 'tlsmail' 
rails_env = ENV['RAILS_ENV'] 
rails_root = ENV['RAILS_ROOT'] 
rake_root = ENV['RAKE_ROOT'] 
num_workers = rails_env == 'production' ? 6 : 1 
# Change cache to my_killer_worker_job if you are testing in development. remember to enable it on config/resque_schedule.yml - Fabian 
queue = rails_env == 'production' ? '*' : 'my_killer_worker_job' 

God::Contacts::Email.defaults do |d| 
    Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) 
    if rails_env == "production" 
    #Change this settings for your own purposes 
    d.from_name = "#{rails_env.upcase}: Process monitoring" 
    d.delivery_method = :smtp 
    d.server_host = 'smtp.gmail.com' 
    d.server_port = 587 
    d.server_auth = :login 
    d.server_domain = 'gmail.com' 
    d.server_user = '[email protected]' 
    d.server_password = 'XXXX' 
    end 
end 



God.contact(:email) do |c| 
    c.name = 'engineering' 
    c.group = 'developers' 
    c.to_email = '[email protected]' 
end 

num_workers.times do |num| 
    God.watch do |w| 
    w.name   = "resque-#{num}" 
    w.group   = 'resque' 
    w.interval  = 30.seconds 
    w.env   = { 'RAILS_ENV' => rails_env, 'QUEUE' => queue, 'VERBOSE' => '1' } 
    w.dir   = rails_root 
    w.start   = "bundle exeC#{rake_root}/rake resque:work" 
    w.start_grace = 10.seconds 
    w.log   = File.join(rails_root, 'log', 'resque-worker.log') 

    # restart if memory gets too high 
    w.transition(:up, :restart) do |on| 
     on.condition(:memory_usage) do |c| 
     c.above = 200.megabytes 
     c.times = 2 
     # c.notify = 'engineering' 
     end 
    end 

    # determine the state on startup 
    w.transition(:init, { true => :up, false => :start }) do |on| 
     on.condition(:process_running) do |c| 
     c.running = true 
     # c.notify = 'engineering' 
     end 
    end 

    # determine when process has finished starting 
    w.transition([:start, :restart], :up) do |on| 
     on.condition(:process_running) do |c| 
     c.running = true 
     c.interval = 5.seconds 
     # c.notify = 'engineering' 
     end 

     # failsafe 
     on.condition(:tries) do |c| 
     c.times = 5 
     c.transition = :start 
     c.interval = 5.seconds 
     # c.notify = 'engineering' 
     end 
    end 

    # start if process is not running 
    w.transition(:up, :start) do |on| 
     on.condition(:process_running) do |c| 
     c.running = false 
     c.notify = {:contacts => ['engineering'], :priority => 1, :category => "workers"} 
     end 
    end 


    end 
end 

S'il vous plaît laissez-moi savoir votre opinion.

+0

avez-vous essayé de sortir du texte à différents endroits dans votre tâche pour voir si elle est jamais exécutée? Aussi, cela se produit-il seulement en production? – MrYoshiji

+0

Oui, il est exécuté parce que je peux voir les travailleurs exécuter les différents travaux de temps en temps. Et oui, cela n'arrive que dans la production. – fabianraf

Répondre

0

On dirait que je suis allé au fond du problème. Sur mon fichier de routes, j'avais ajouté un appel à une méthode pour charger des routes dynamiques et j'avais l'impression que resque ne l'aimait pas et continuait à tuer les processus sans rien dire (encore très bizarre). Cependant, après avoir supprimé cette ligne (DynamicRouter.load) les travailleurs ont arrêté le comportement fou. J'espère que cela aidera quelqu'un d'autre et je serai heureux de donner plus de détails sur ce que je pourrais trouver.