When i restart mysql, all apps served by thin fail on the first hit because the mysql connection is closed. This looks like this in logs: -------------------------------------------- ActiveRecord::StatementInvalid (Mysql::Error: MySQL server has gone away: SHOW FIELDS FROM `settings`): app/models/setting.rb:152:in `check_cache' app/controllers/application_controller.rb:58:in `user_setup' thin (1.2.11) lib/thin/connection.rb:84:in `pre_process' thin (1.2.11) lib/thin/connection.rb:82:in `catch' thin (1.2.11) lib/thin/connection.rb:82:in `pre_process' thin (1.2.11) lib/thin/connection.rb:57:in `process' thin (1.2.11) lib/thin/connection.rb:42:in `receive_data' eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine' eventmachine (0.12.10) lib/eventmachine.rb:256:in `run' thin (1.2.11) lib/thin/backends/base.rb:61:in `start' thin (1.2.11) lib/thin/server.rb:159:in `start' thin (1.2.11) lib/thin/controllers/controller.rb:86:in `start' thin (1.2.11) lib/thin/runner.rb:185:in `send' thin (1.2.11) lib/thin/runner.rb:185:in `run_command' thin (1.2.11) lib/thin/runner.rb:151:in `run!' thin (1.2.11) bin/thin:6 /usr/bin/thin:8:in `load' /usr/bin/thin:8 -------------------------------------------- For each site, there's one such error and then it works ok. My guess it that thin/rails has persistent mysql connections, which are re-created on errors such as this one. So i think the init.d script should be modified so that restarting mysql will trigger a restart of thin, but i dont know how to do this..? I understand not everybody uses mysql, so maybe this should be commented in the init.d script and people would optionnally uncomment it.
In this case you should set your own extra dependencies like this, in /etc/conf.d/thin: rc_need="mysql" The init script should not be changed.
ok, i did not know that this was possible. This indeed fixes my issue. Sorry for the noise.