This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update how we provision and deploy to server
- Loading branch information
1 parent
8157a1c
commit 9135ed5
Showing
12 changed files
with
293 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'highline/import' | ||
require 'erb' | ||
|
||
# Require our stack | ||
Dir[File.join(File.dirname(__FILE__), 'stack', '*.rb')].each do |lib| | ||
require lib | ||
end | ||
|
||
policy :watchdog_stack, :roles => :provision do | ||
requires :ruby_enterprise | ||
requires :nginx_passenger | ||
requires :nginx_conf | ||
requires :nginx_init | ||
requires :git | ||
requires :monit | ||
requires :monit_conf | ||
requires :rack | ||
requires :sinatra | ||
requires :sqlite | ||
requires :sqlite_driver | ||
end | ||
|
||
deployment do | ||
# mechanism for deployment | ||
delivery :capistrano do | ||
begin | ||
recipes 'Capfile' | ||
rescue LoadError | ||
recipes 'deploy' | ||
end | ||
|
||
default_run_options[:pty] = true | ||
set :use_sudo, true | ||
role :provision, ask("Enter the IP address or hostname to provision: ") | ||
set :user, ask("Enter your username on the host to provision: ") { |q| q.default = ENV['USER'] } | ||
end | ||
|
||
# source based package installer defaults | ||
source do | ||
prefix '/usr/local' | ||
archives '/usr/local/sources' | ||
builds '/usr/local/build' | ||
end | ||
end | ||
|
||
# Depend on a specific version of sprinkle | ||
begin | ||
gem 'sprinkle', ">= 0.2.6" | ||
rescue Gem::LoadError | ||
puts "sprinkle 0.2.6 required.\n Run: `gem install sprinkle`" | ||
exit | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package :dependencies do | ||
apt %w(libglib2.0-dev cmake libpcre3 libpcre3-dev libxml2-dev | ||
libxml2 libxslt-dev libgcrypt11-dev libreadline5-dev zlib1g-dev zlibc | ||
libedit-dev gettext logrotate libcurl4-openssl-dev | ||
libevent-dev libevent-1.4-2 openssl libssl-dev) | ||
requires :build_essential | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package :build_essential do | ||
description 'Build tools' | ||
apt 'build-essential' do | ||
pre :install, 'apt-get update' | ||
pre :install, 'apt-get upgrade' | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#! /bin/sh | ||
|
||
# Provides: nginx | ||
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and | ||
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your | ||
# distro. | ||
# | ||
# Author: Ryan Norbauer <ryan.norbauer@gmail.com> | ||
# Modified: Geoffrey Grosenbach http://topfunky.com | ||
|
||
set -e | ||
|
||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | ||
DESC="nginx daemon" | ||
NAME=nginx | ||
DAEMON=/usr/local/nginx/sbin/$NAME | ||
CONFIGFILE=/usr/local/nginx/conf/nginx.conf | ||
PIDFILE=/var/run/$NAME.pid | ||
SCRIPTNAME=/etc/init.d/$NAME | ||
|
||
# Gracefully exit if the package has been removed. | ||
test -x $DAEMON || exit 0 | ||
|
||
d_start() { | ||
$DAEMON -c $CONFIGFILE || echo -n " already running" | ||
} | ||
|
||
d_stop() { | ||
kill -QUIT `cat $PIDFILE` || echo -n " not running" | ||
} | ||
|
||
d_reload() { | ||
kill -HUP `cat $PIDFILE` || echo -n " can't reload" | ||
} | ||
|
||
case "$1" in | ||
start) | ||
echo -n "Starting $DESC: $NAME" | ||
d_start | ||
echo "." | ||
;; | ||
stop) | ||
echo -n "Stopping $DESC: $NAME" | ||
d_stop | ||
echo "." | ||
;; | ||
reload) | ||
echo -n "Reloading $DESC configuration..." | ||
d_reload | ||
echo "reloaded." | ||
;; | ||
restart) | ||
echo -n "Restarting $DESC: $NAME" | ||
d_stop | ||
# One second might not be time enough for a daemon to stop, | ||
# if this happens, d_start will fail (and dpkg will break if | ||
# the package is being upgraded). Change the timeout if needed | ||
# be, or change d_stop to have start-stop-daemon use --retry. | ||
# Notice that using --retry slows down the shutdown process somewhat. | ||
sleep 1 | ||
d_start | ||
echo "." | ||
;; | ||
*) | ||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 | ||
exit 3 | ||
;; | ||
esac | ||
|
||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package :rack do | ||
gem 'rack' | ||
version '1.1.0' | ||
end | ||
|
||
package :sinatra do | ||
gem 'sinatra' | ||
version '1.1.0' | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package :git, :provides => :scm do | ||
description 'Git Distributed Version Control' | ||
version '1.7.3.5' | ||
source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz" | ||
requires :git_dependencies | ||
|
||
verify do | ||
has_file '/usr/local/bin/git' | ||
end | ||
end | ||
|
||
package :git_dependencies do | ||
description 'Git Build Dependencies' | ||
apt 'git-core', :dependencies_only => true | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package :monit, :provides => :monitoring do | ||
description 'installs monit - a system monitoring utility which allows an admin to easily monitor files, processes, directories, or devices on your system.' | ||
|
||
apt "monit" | ||
|
||
requires :build_essential, :dependencies | ||
|
||
verify do | ||
has_executable "monit" | ||
end | ||
end | ||
|
||
package :monit_conf do | ||
description "Monit conf file" | ||
requires :monit | ||
install_path "/etc/monit/monitrc" | ||
|
||
transfer 'config/stack/files/monitrc.conf', "/tmp/monitrc" do | ||
post :install, "mv -f /tmp/monitrc /etc/monit/monitrc" | ||
post :install, "chown root:root /etc/monit/monitrc" | ||
post :install, "chmod u=rw,go= /etc/monit/monitrc" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package :nginx_passenger, :provides => [:webserver, :appserver] do | ||
description "Nginx with the Passenger module" | ||
version "0.8.54" | ||
install_path "/usr/local/nginx" | ||
|
||
source "http://sysoev.ru/nginx/nginx-#{version}.tar.gz" do | ||
custom_install "sudo /usr/local/bin/passenger-install-nginx-module " + | ||
"--auto --prefix=#{install_path} --nginx-source-dir=/usr/local/build/nginx-#{version} " + | ||
"--extra-configure-flags='--with-http_ssl_module'" | ||
post :install, "ln -s #{install_path}/sbin/nginx /usr/local/bin/nginx" | ||
post :install, "chown -R deploy /usr/local/nginx/logs" | ||
post :install, "mkdir /var/www" | ||
post :install, "chown -R deploy /var/www" | ||
end | ||
|
||
verify do | ||
has_directory "/usr/local/nginx" | ||
has_file "/usr/local/nginx/conf/nginx.conf" | ||
has_executable "/usr/local/nginx/sbin/nginx" | ||
end | ||
|
||
requires :ruby_enterprise, :build_essential, :dependencies | ||
end | ||
|
||
package :nginx_init do | ||
description "Nginx init.d file for Ubuntu" | ||
install_path "/etc/init.d" | ||
|
||
transfer 'config/stack/files/nginx-init.sh', '/tmp/nginx' do | ||
post :install, "mv -f /tmp/nginx /etc/init.d/nginx" | ||
post :install, "chmod +x /etc/init.d/nginx" | ||
post :install, "/usr/sbin/update-rc.d -f nginx defaults" | ||
post :install, "/etc/init.d/nginx start" | ||
end | ||
|
||
requires :nginx_passenger | ||
end | ||
|
||
package :nginx_conf do | ||
description "Sample Nginx conf file" | ||
install_path "/usr/local/nginx/conf/nginx.conf" | ||
|
||
transfer 'config/stack/files/nginx.conf.sample', '/tmp/nginx.conf' do | ||
post :install, "mv -f /tmp/nginx.conf /usr/local/nginx/conf/nginx.conf" | ||
end | ||
|
||
requires :nginx_passenger | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package :ruby_enterprise do | ||
description 'Ruby Enterprise Edition' | ||
version '1.8.7-2010.02' | ||
|
||
install_path = "/usr/local/ruby-enterprise" | ||
binaries = %w(erb gem irb passenger-config passenger-install-apache2-module passenger-install-nginx-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test rackup rails rake rdoc ree-version ri ruby testrb) | ||
source "http://rubyforge.org/frs/download.php/71096/ruby-enterprise-#{version}.tar.gz" do | ||
custom_install './installer --auto=/usr/local/ruby-enterprise' | ||
|
||
binaries.each {|bin| post :install, "ln -s #{install_path}/bin/#{bin} /usr/local/bin/#{bin}" } | ||
end | ||
|
||
verify do | ||
has_directory install_path | ||
has_executable "#{install_path}/bin/ruby" | ||
binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{install_path}/bin/#{bin}" } | ||
end | ||
|
||
requires :dependencies | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package :sqlite, :provides => :database do | ||
description 'SQLite 3 Database' | ||
apt 'sqlite3' | ||
|
||
verify do | ||
has_executable 'sqlite3' | ||
end | ||
|
||
requires :build_essential | ||
optional :sqlite_driver | ||
end | ||
|
||
package :sqlite_driver, :provides => :ruby_database_driver do | ||
description 'Ruby SQLite database driver' | ||
apt 'libsqlite3-dev' | ||
gem 'sqlite3-ruby' | ||
|
||
verify do | ||
has_gem 'sqlite3-ruby' | ||
end | ||
|
||
requires :ruby_enterprise | ||
end |