mysociety / alaveteli

Provide a Freedom of Information request system for your jurisdiction
https://alaveteli.org
Other
389 stars 196 forks source link

Restarting thin daemon when there is no process running breaks #2664

Open garethrees opened 9 years ago

garethrees commented 9 years ago
vagrant  20208  0.0  0.0   9392   924 pts/0    S+   09:53   0:00 grep --color=auto thin
vagrant@vagrant-ubuntu-precise-64:~$ sudo /etc/init.d/alaveteli restart
Restarting Alaveteli app server: /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.pid (Thin::PidFileNotFound)
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/daemonizing.rb:119:in `restart'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/controllers/controller.rb:103:in `restart'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/controllers/controller.rb:134:in `tail_log'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/controllers/controller.rb:102:in `restart'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/runner.rb:187:in `send'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
    from /home/alaveteli/bundle/ruby/1.8/gems/thin-1.5.1/bin/thin:6
    from /home/alaveteli/bundle/ruby/1.8/bin/thin:19:in `load'
    from /home/alaveteli/bundle/ruby/1.8/bin/thin:19
alaveteli.
schlos commented 1 year ago

This is still reproducible on Ubuntu 18.04 LTS (while Thin process is running):

imamopravoznati:/var/www/imamopravoznati.org/alaveteli$ sudo /etc/init.d/alaveteli restart
Restarting Alaveteli app server: Traceback (most recent call last):
    9: from /home/alaveteli/bundle/ruby/2.5.0/bin/thin:23:in `<main>'
    8: from /home/alaveteli/bundle/ruby/2.5.0/bin/thin:23:in `load'
    7: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/bin/thin:6:in `<top (required)>'
    6: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/runner.rb:159:in `run!'
    5: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/runner.rb:203:in `run_command'
    4: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:103:in `restart'
    3: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:135:in `tail_log'
    2: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:104:in `block in restart'
    1: from /home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/daemonizing.rb:127:in `restart'
/home/alaveteli/bundle/ruby/2.5.0/gems/thin-1.8.1/lib/thin/daemonizing.rb:148:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.pid (Thin::PidFileNotFound)
alaveteli.

To confirm Thin process is running:

imamopravoznati:/var/www/imamopravoznati.org/alaveteli$ pgrep -u alaveteli | tail -n 1
27913

In this case, Thin PID is "27913".

Thin PID is correctly stored:

imamopravoznati:/var/www/imamopravoznati.org/alaveteli/tmp/pids$ less thin.3000.pid
27913

But it seems restart daemon is trying to fetch a thin pid from different file: "Can't stop process, no PID found in tmp/pids/thin.pid (Thin::PidFileNotFound)" --> tmp/pids/thin.pid instead of "tmp/pids/thin.3000.pid"

garethrees commented 1 year ago

That's strange. We rely on thin to know how to restart itself. Maybe this is a known bug with thin? I don't think it's anything we're doing.

FWIW, we're looking at moving to puma, as that's now Rails' default application server.