Permalink
Browse files

appserver dep tree looks done ftw!

  • Loading branch information...
1 parent bef5396 commit 3669c4b13c31a860a13196ff591f4e7fb2a27fde @geelen geelen committed Nov 5, 2010
Showing with 44 additions and 2 deletions.
  1. +1 −1 monit.rb
  2. +5 −1 nginx.rb
  3. +38 −0 utils.rb
View
@@ -1,6 +1,6 @@
# Installs and configures monit. Like a boss.
-dep 'monit running' do
+dep 'monit running' do #DONE
requires 'monit'
requires_when_unmet 'monit startable'
met? { (status = sudo("monit status")) && status[/uptime/] }
View
@@ -5,8 +5,12 @@
define_var :nginx_prefix, :default => '/opt/nginx'
end
-dep 'nginx running', :template => 'benhoskings:nginx' do
+dep 'nginx running' do #DONE
define_var :nginx_prefix, :default => '/opt/nginx'
+ helper :nginx_running? do
+ shell "netstat -an | grep -E '^tcp.*[.:]80 +.*LISTEN'"
+ end
+
met? {
returning nginx_running? do |result|
log "There is #{result ? 'something' : 'nothing'} listening on #{result ? result.scan(/[0-9.*]+[.:]80/).first : 'port 80'}"
View
@@ -0,0 +1,38 @@
+# Throw a current_app, console and db shortcut in your home directory.
+
+dep 'handy utils' do
+ requires 'current_app symlink', #DONE
+ 'console shortcut', #DONE
+ 'db shortcuts' #DONE
+end
+
+dep 'current_app symlink' do #DONE
+ met? { var(:symlink).p.exists? }
+ meet { shell "ln -s #{var(:rails_root).p} #{var(:symlink).p}" }
+end
+
+dep 'console shortcut' do #DONE
+ requires 'current_app symlink'
+ helper(:shortcut_contents) { %Q{#!/bin/bash
+cd current_app && script/console #{var(:rails_env)}
+ } }
+ helper(:shortcut_file) { "~/console".p }
+ met? { shortcut_file.exists? && shortcut_file.executable_real? }
+ meet {
+ shell "cat > #{shortcut_file}", :input => shortcut_contents
+ shell "chmod +x #{shortcut_file}"
+ }
+end
+
+dep 'db shortcuts' do #DONE
+ requires 'current_app symlink' #DONE
+ helper(:shortcut_contents) { %Q{#!/bin/bash
+cd current_app && script/dbconsole -p #{var(:rails_env)}
+ } }
+ helper(:shortcut_file) { "~/db".p }
+ met? { shortcut_file.exists? && shortcut_file.executable_real? }
+ meet {
+ shell "cat > #{shortcut_file}", :input => shortcut_contents
+ shell "chmod +x #{shortcut_file}"
+ }
+end

0 comments on commit 3669c4b

Please sign in to comment.