Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Removed settings for pids_dir, sockets_dir, server_log and access_log…
Browse files Browse the repository at this point in the history
…. Placing those files outside the application directories to make application updates easier
  • Loading branch information
zargony committed Apr 28, 2010
1 parent 9a8b78f commit 25f24d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
22 changes: 13 additions & 9 deletions lib/appserver/app.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
module Appserver
class App < Struct.new(:server, :name, :unicorn, :environment, :instances, :pids_dir, :sockets_dir,
:server_log, :max_cpu_usage, :max_memory_usage, :usage_check_cycles,
:http_check_timeout, :hostname, :access_log, :public_dir)
class App < Struct.new(:server, :name, :unicorn, :environment, :instances,
:max_cpu_usage, :max_memory_usage, :usage_check_cycles,
:http_check_timeout, :hostname, :public_dir)
DEFAULTS = {
:unicorn => '/usr/local/bin/unicorn',
:environment => 'production',
:instances => 3,
:pids_dir => 'tmp/pids',
:sockets_dir => 'tmp/sockets',
:server_log => 'log/server.log',
:max_cpu_usage => nil,
:max_memory_usage => nil,
:usage_check_cycles => 5,
:http_check_timeout => 30,
:hostname => `/bin/hostname -f`.chomp.gsub(/^[^.]+\./, ''),
:access_log => 'log/access.log',
:public_dir => 'public',
}

Expand Down Expand Up @@ -46,11 +42,19 @@ def rack?
end

def pid_file
File.join(pids_dir, 'unicorn.pid')
File.join(server.tmp_dir, "#{name}.pid")
end

def socket
File.join(sockets_dir, 'unicorn.socket')
File.join(server.tmp_dir, "#{name}.socket")
end

def server_log
File.join(server.log_dir, "#{name}.server.log")
end

def access_log
File.join(server.log_dir, "#{name}.access.log")
end

def write_monit_config (f)
Expand Down
16 changes: 0 additions & 16 deletions lib/appserver/appserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@
# Default number of application instances (unicorn workers)
#instances: 3

# Path where to store pid files of running instances. Defaults to the
# tmp/pids directory in the application
#pids_dir: tmp/pids

# Path where to store sockets of running instances. Defaults to the
# tmp/sockets directory in the application
#sockets_dir: tmp/sockets

# Path/name of the logfile for instance servers. Defaults to log/server.log
# in the application
#server_log: log/server.log

# Let Monit watch the CPU usage of instances and restart them if their
# CPU usage exceeds this value
#max_cpu_usage:
Expand Down Expand Up @@ -82,10 +70,6 @@
# directory in the application
#public_dir: public

# Path/name of the logfile for request logging. Defaults to log/access.log
# in the application
#access_log: log/access.log


#
# APPLICATIONS
Expand Down
11 changes: 11 additions & 0 deletions lib/appserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def self.initialize_dir (options = {})
safe_replace_file('appserver.yml') do |f|
f.puts File.read(config_file_template)
end
['tmp', 'log'].each do |dir|
Dir.mkdir(dir) if !File.directory?(dir)
end
end

def initialize (options = {})
Expand All @@ -55,6 +58,14 @@ def config_file
File.join(dir, 'appserver.yml')
end

def tmp_dir
File.join(dir, 'tmp')
end

def log_dir
File.join(dir, 'log')
end

def app (name)
@apps ||= {}
@apps[name] ||= App.new(self, name, @config)
Expand Down

0 comments on commit 25f24d3

Please sign in to comment.