# ADD DELETE OF PUMA SOCKET IN PRE-START
# FIX FOR MYSQL
# FIX TO BE LIKE THE ONE WORKING ON HORSE!

<% ruby_version     = "1.9.3" if ruby_version.nil? %>
# bluepill - process monitor - 
# Rails application: <%= "#{application}" %>
# Environment: <%= "#{rails_env}" %>
#
# simple process monitoring tool

description     "Simple process monitoring tool for <%= "#{application}" %> - <%= "#{rails_env}" %>"

#start on runlevel [2345]
start on (local-filesystems and net-device-up IFACE=eth0 and running mongodb)
stop on shutdown

expect daemon
# respawn

pre-start script
  echo "Pre-start <%= "#{application}" %>"
  mkdir -p /var/run/bluepill
  chown -R <%= "#{user}:#{group}" %> /var/run/bluepill
end script

pre-stop script
  echo "Pre-stop <%= "#{application}" %>"
  # When running RVM system-wide this should work:
  exec su - -c "cd <%= "#{current_path}" %>; RAILS_ENV=<%= "#{rails_env}" %> bundle exec bluepill stop <%= "#{application}_#{rails_env}"%> --no-privileged" <%= "#{user}" %>
end script

script
  echo "Starting <%= "#{application}" %>"
  # When running RVM system-wide this should work:
  exec su - -c "cd <%= "#{current_path}" %>; RAILS_ENV=<%= "#{rails_env}" %> bundle exec bluepill load <%= "#{bluepill_remote_config}" %> --no-privileged" <%= "#{user}" %>
end script

# bluepill - process monitor - 
# Rails application: <%= "#{application}" %>
# Environment: <%= "#{rails_env}" %>
#
# simple process monitoring tool

description     "Simple process monitoring tool for <%= "#{application}" %> - <%= "#{rails_env}" %>"

#start on runlevel [2345]
start on (local-filesystems and net-device-up IFACE=eth0 and running <%= database %>})
stop on shutdown

expect daemon
# respawn

pre-start script
  echo "Pre-start <%= "#{application}" %>"
  mkdir -p /var/run/bluepill
  chown -R <%= "#{user}:#{group}" %> /var/run/bluepill
  <%= "rm -f /web/#{rails_env}/#{application}/shared/sockets/puma.sock" if bluepill_use_puma == true %>
end script

pre-stop script
  echo "Pre-stop <%= "#{application}" %>"
  # When running RVM system-wide this should work:
  exec su - -c "cd <%= "#{current_path}" %>; RAILS_ENV=<%= "#{rails_env}" %> bundle exec bluepill stop <%= "#{application}_#{rails_env}"%> --no-privileged" <%= "#{user}" %>
end script

script
  echo "Starting <%= "#{application}" %>"
  # When running RVM system-wide this should work:
  exec su - -c "cd <%= "#{current_path}" %>; RAILS_ENV=<%= "#{rails_env}" %> bundle exec bluepill load <%= "#{bluepill_remote_config}" %> --no-privileged" <%= "#{user}" %>
end script

Fix db requirement and puma socket hanging for bluepill init
Fix db requirement and puma socket hanging for bluepill init
