Last active
December 14, 2015 19:58
-
-
Save bryanthompson/5140228 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'bundler/vlad' | |
set :application, "project-name" | |
set :domain, "server-name-in-ssh-config" | |
set :deploy_to, "/var/www/html/#{application}" | |
set :repository, "ssh://[email protected]/bryanthompson/#{application}.git" | |
namespace :vlad do | |
namespace :ec2 do | |
desc "deploys latest code, symlinks media, stops and starts service" | |
remote_task :deploy => %w(update prepare bundle stop start) | |
desc "bundle install gems on production" | |
remote_task :bundle, :roles => :app do | |
run "cp #{deploy_to}/current/config/nginx.project.conf /etc/nginx/conf.d/unicorn_sites/project.conf" | |
run "cd #{deploy_to}/current; bundle --without development install" | |
end | |
desc "prepares permissions and media symlinks" | |
remote_task :prepare, :roles => :app do | |
run "cd #{deploy_to}/current && ln -s #{deploy_to}/media ." | |
end | |
%w(start stop).each do |task| | |
desc "#{task.capitalize} this pedia site on production" | |
remote_task task, :roles => :app do | |
run "#{deploy_to}/current/bin/unicorn.sh #{task}" | |
end | |
end | |
end | |
end |
This file contains hidden or 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 1 | |
timeout 30 | |
listen "/var/run/unicorn/project.sock" | |
pid "/var/run/unicorn/project.pid" | |
stderr_path "/var/log/nginx/project-unicorn-stderr.log" |
This file contains hidden or 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 | |
UNICORN=$rvm_path/gems/$RUBY_VERSION/bin/unicorn | |
KILL=/bin/kill | |
APP_ROOT=/var/www/html/project/current | |
PID=/var/run/unicorn/project.pid | |
GEM_HOME=$rvm_path/gems/$RUBY_VERSION | |
sig () { | |
test -s "$PID" && kill -$1 `cat $PID` | |
} | |
case "$1" in | |
start) | |
echo "Starting unicorn..." | |
cd $APP_ROOT | |
$UNICORN -D -E production -c $APP_ROOT/config/unicorn.conf | |
;; | |
stop) | |
sig QUIT && exit 0 | |
echo >&2 "Not running" | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
status) | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment