Skip to content
Browse files

Overhauled and finished deployment script

  • Loading branch information...
1 parent 399e036 commit 780eed915023cf8d867a6f6319d1cf560297c6b2 @ndbroadbent committed Mar 17, 2011
Showing with 79 additions and 5 deletions.
  1. +67 −5 Capfile
  2. +7 −0 script/start_processes.sh
  3. +5 −0 script/stop_processes.sh
View
72 Capfile
@@ -1,7 +1,69 @@
-load 'deploy' if respond_to?(:namespace) # cap2 differentiator
-# Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
+set :application, "octopus_access_control"
+set :hostname, "lock-10c"
+set :user, "tc"
-require 'rubygems'
-require 'railsless-deploy'
-load 'config/deploy'
+set :local_path, File.dirname(__FILE__)
+set :transfer_to, "/tmp"
+set :deploy_to, "/mnt/sda1"
+set :shared_path, "#{deploy_to}/shared"
+set :current_path, "#{deploy_to}/#{application}"
+
+# ------------------------------------------------------
+desc "Package application"
+task :build_package do
+ puts "== Packaging application..."
+ %x[cd #{local_path} && \
+ tar -czpvf /tmp/#{application}.tar.gz #{local_path} --exclude=.git]
+ puts "===== #{application}.tar.gz was created."
+end
+
+# ------------------------------------------------------
+desc "Transfer package to target"
+task :transfer_package do
+ puts "== Transferring to Evo T20 (#{hostname})..."
+ %x[scp /tmp/#{application}.tar.gz #{user}@#{hostname}:#{transfer_to}]
+ puts "===== Package transferred."
+end
+
+# ------------------------------------------------------
+desc "Install the application on your iPhone"
+task :install, :hosts => "#{hostname}" do
+ run <<-CMD
+ sudo rm -rf #{current_path};
+ sudo mkdir -p #{current_path};
+ cd #{current_path};
+ sudo tar -xzpvf #{transfer_to}/#{application}.tar.gz;
+ rm -f #{transfer_to}/#{application}.tar.gz;
+ CMD
+end
+
+# ------------------------------------------------------
+desc "Symlink shared config files"
+task :symlink_shared, :hosts => "#{hostname}" do
+ sudo "ln -fs #{shared_path}/config.yml #{current_path}/config/"
+ sudo "ln -fs #{shared_path}/authorized_users.yml #{current_path}/config/"
+ sudo "ln -fs #{shared_path}/user_radio_prefs.yml #{current_path}/config/"
+end
+
+# ------------------------------------------------------
+namespace :processes do
+ desc "Kill running processes"
+ task :stop, :hosts => "#{hostname}" do; run "cd #{current_path} && sudo ./script/stop_processes.sh"; end
+ # ------------------------------------------------------
+ desc "Start processes"
+ task :start, :hosts => "#{hostname}" do; run "cd #{current_path} && sudo ./script/start_processes.sh &"; end
+ # ------------------------------------------------------
+ desc "Restart processes"
+ task :restart, :hosts => "#{hostname}" do; stop; start; end
+end
+
+# ------------------------------------------------------
+desc "Package and install the application on your iPhone"
+task :deploy, :hosts => "#{hostname}" do
+ build_package
+ transfer_package
+ install
+ symlink_shared
+ processes.restart
+end
View
7 script/start_processes.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+this_dir=$(cd `dirname $0` && pwd)
+nohup ruby $this_dir/../octopus_sinatra.rb -p 80 > /dev/null 2>&1 &
+sleep 10
+nohup ruby $this_dir/../octopus_daemon.rb > /dev/null 2>&1 &
+nohup ruby $this_dir/../weather_daemon.rb > /dev/null 2>&1 &
+
View
5 script/stop_processes.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+pid=$(pgrep -f 'octopus_sinatra'); if [ $pid ]; then sudo kill -9 $pid; fi
+pid=$(pgrep -f 'octopus_daemon'); if [ $pid ]; then sudo kill -9 $pid; fi
+pid=$(pgrep -f 'weather_daemon'); if [ $pid ]; then sudo kill -9 $pid; fi
+

0 comments on commit 780eed9

Please sign in to comment.
Something went wrong with that request. Please try again.