Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Add Angel module and servers
  • Loading branch information
geoffgarside committed Apr 17, 2008
1 parent 30564f5 commit 3cb0e4b
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Manifest.txt
Expand Up @@ -7,6 +7,10 @@ Rakefile
config/hoe.rb
config/requirements.rb
lib/angel.rb
lib/angel/servers.rb
lib/angel/servers/ebb.rb
lib/angel/servers/mongrel.rb
lib/angel/servers/thin.rb
lib/angel/version.rb
script/console
script/destroy
Expand Down
36 changes: 34 additions & 2 deletions lib/angel.rb
Expand Up @@ -2,5 +2,37 @@
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))

module Angel

end
def self.set_pid_file(config)
unless config['pid_file'][0].chr == '/'
config['pid_file'] = File.join(config['cwd'], config['pid_file'])
end

config['pid_file'] = config['pid_file'].gsub(/\.pid$/, ".#{config['port']}.pid")
end

def self.set_log_file(config)
unless config['log_file'][0].chr == '/'
config['log_file'] = File.join(config['cwd'], config['log_file'])
end

config['log_file'] = config['log_file'].gsub(/\.log$/, ".#{config['port']}.log")
end

def self.process_name(config)
"#{config['app']}-cluster-#{config['port']}"
end

def self.start_cmd(config)
self.send(:"start_#{config['web_server']}", config)
end

def self.stop_cmd(config)
self.send(:"stop_#{config['web_server']}", config)
end

def self.restart_cmd(config)
self.send(:"restart_#{config['web_server']}", config)
end
end

require 'servers'
3 changes: 3 additions & 0 deletions lib/angel/servers.rb
@@ -0,0 +1,3 @@
require 'servers/mongrel'
require 'servers/thin'
require 'servers/ebb'
18 changes: 18 additions & 0 deletions lib/angel/servers/ebb.rb
@@ -0,0 +1,18 @@
module Angel
def self.start_ebb(config)
"ebb_rails start " + [['-d'],
['-p', config['port']],
['-c', config['cwd']],
['-P', config['pid_file']],
['-l', config['log_file']],
['-e', config['environment']]].join(' ')
end

def self.stop_ebb(config)
"ebb_rails stop -P #{config['pid_file']}"
end

def self.restart_ebb(config)
stop_ebb + " && " + start_ebb
end
end
19 changes: 19 additions & 0 deletions lib/angel/servers/mongrel.rb
@@ -0,0 +1,19 @@
module Angel
def self.start_mongrel(config)
"mongrel_rails start " + [['-d'],
['-p', config['port']],
['-c', config['cwd']],
['-a', config['address']],
['-P', config['pid_file']],
['-l', config['log_file']],
['-e', config['environment']]].join(' ')
end

def self.stop_mongrel(config)
"mongrel_rails stop -P #{config['pid_file']}"
end

def self.restart_mongrel(config)
"mongrel_rails restart -P #{config['pid_file']}"
end
end
19 changes: 19 additions & 0 deletions lib/angel/servers/thin.rb
@@ -0,0 +1,19 @@
module Angel
def self.start_thin(config)
"thin start " + [['-d'],
['-p', config['port']],
['-c', config['cwd']],
['-a', config['address']],
['-P', config['pid_file']],
['-l', config['log_file']],
['-e', config['environment']]].join(' ')
end

def self.stop_thin(config)
"thin stop -P #{config['pid_file']}"
end

def self.restart_thin(config)
"thin restart -P #{config['pid_file']}"
end
end

0 comments on commit 3cb0e4b

Please sign in to comment.