-
-
Save riywo/2408821 to your computer and use it in GitHub Desktop.
unicorn with daemontools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mkdir /service/redmine-unicorn | |
# cd /service/redmine-unicorn | |
# mkdir env | |
# echo "production" > env/RAILS_ENV | |
# echo "/home/riywo/redmine" > env/RAILS_ROOT | |
# echo "/home/riywo/.rbenv" > env/RBENV_ROOT | |
# echo "riywo" > env/USER | |
exec 2>&1 \ | |
envdir ./env \ | |
sh -c ' | |
PATH="$RBENV_ROOT/bin:$PATH" | |
eval "$(rbenv init -)" | |
cd $RAILS_ROOT | |
exec setuidgid $USER \ | |
bundle exec unicorn_rails -c ./config/unicorn.conf.rb -E $RAILS_ENV | |
' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 4 | |
listen 8080, :tcp_nopush => true | |
timeout 30 | |
pid File.expand_path("tmp/pids/unicorn.pid", ENV['RAILS_ROOT']) | |
stderr_path File.expand_path("log/unicorn.stderr.log", ENV['RAILS_ROOT']) | |
stdout_path File.expand_path("log/unicorn.stdout.log", ENV['RAILS_ROOT']) | |
preload_app true | |
GC.respond_to?(:copy_on_write_friendly=) and | |
GC.copy_on_write_friendly = true | |
before_fork do |server, worker| | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.connection.disconnect! | |
end | |
after_fork do |server, worker| | |
defined?(ActiveRecord::Base) and | |
ActiveRecord::Base.establish_connection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment