Commits

Alan Stevens committed d2f1ec7

Updated the generate script to find its location

Comments (0)

Files changed (2)

.skel/config/site.pill

   app.working_dir = 'SITE_ROOT/current'
   app.uid = 'www-data'
   app.gid = 'www-data'
-  app.environment = { 'RAILS_ENV' => 'production' }
+  app.environment = `env -i BUNDLE_GEMFILE=SITE_ROOT/Gemfile bundle exec env`.lines.inject({}) do |env_hash,l|
+    kv = l.chomp.split('=',2)
+    env_hash[kv[0] = kv[1]
+    env_hash
+  end
   app.process("unicorn") do |process|
     process.pid_file = "SITE_ROOT/current/tmp/pids/unicorn.pid"
     process.working_dir = SITE_ROOT
 
-    process.start_command = "bundle exec unicorn_rails -Dc SITE_ROOT/config/unicorn.rb -E production"
+    process.start_command = "exec unicorn_rails -Dc SITE_ROOT/config/unicorn.rb -E production"
     process.stop_command = "kill -QUIT {{PID}}"
     process.restart_command = "kill -USR2 {{PID}}"
 
     process.uid = process.gid = 'deploy'
 
-    process.start_grace_time = 8.seconds
-    process.stop_grace_time = 5.seconds
-    process.restart_grace_time = 13.seconds
+    process.start_grace_time = 30.seconds
+    process.stop_grace_time = 30.seconds
+    process.restart_grace_time = 30.seconds
 
 
     process.monitor_children do |child_process|
 #!/bin/bash
 set -e
-www_root=$PWD
-vhost_skel=$www_root/.skel
-
 domain_name=$1
 
-if [ "$domain_name" = "" ] ; then
+www_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd
+
+if [ "$domain_name" -eq "" ] ; then
   echo -e "Specify the virtual host domain name:"
   read domain_name
 fi
 
-if [ "$domain_name" = "" ] ; then
+if [ "$domain_name" -eq "" ] ; then
 	echo "Invalid domain!"
 	exit 1;
 fi
 
 site_root="$www_root/$domain_name"
 
-cp -Rf "$vhost_skel/" "$site_root"
+cp -Rf "$www_root/.skel/" "$site_root"
 
 ack-grep -l SITE_ROOT $site_root/config/* | xargs -t -n 1 sed -i -e "s@SITE_ROOT@$site_root@g"
 ack-grep -l DOMAIN_NAME $site_root/config/* | xargs -t -n 1 sed -i -e "s@DOMAIN_NAME@$domain_name@g"
 #
 # append the application's pill to bluepill startup
 #
-echo "exec /usr/local/rvm/bin/global_bluepill load $site_root/config/site.pill" | sudo tee -a /etc/init/blue_pill.conf
+echo "require $site_root/config/site.pill" | sudo tee -a /etc/bluepill/all_sites.pill
 
-#
-# Create a init script for Unicorn
-#
-chmod +x "$site_root/config/unicorn"
-sudo mv "$site_root/config/unicorn" "/etc/init.d/${domain_name}_unicorn"
-
-#
-# start Unicorn
-#
-sudo "/etc/init.d/${domain_name}_unicorn" start
-
-#
-# add unicorn to the default run levels
-#
-sudo /usr/sbin/update-rc.d -f ${domain_name}_unicorn defaults
+sudo restart bluepill
 
 echo "Skeleton copied to \"$site_root\""