Class: Sunshine::Apache

Inherits:
Server show all
Defined in:
lib/sunshine/daemons/apache.rb

Overview

A wrapper for configuring the apache2 server. Note: Due to Apache default limitations, the @connections attribute defaults to 256.

Note: The minimum timeout supported by Apache is 1 second.

Constant Summary

Constants inherited from Daemon

Daemon::RESTART_FAILED_CODE, Daemon::START_FAILED_CODE, Daemon::STATUS_DOWN_CODE, Daemon::STOP_FAILED_CODE

Instance Attribute Summary collapse

Attributes inherited from Server

#cluster, #connections, #port, #server_name, #sigkill, #target

Attributes inherited from Daemon

#app, #bin, #config_file, #config_path, #config_template, #name, #pid, #processes, #restart_cmd, #server_apps, #status_cmd, #stop_cmd, #sudo, #timeout

Instance Method Summary collapse

Methods inherited from Server

binder_methods, new_cluster, passenger_root, #supports_passenger?, #supports_rack?, #use_passenger?

Methods inherited from Daemon

#_restart_cmd, #_start_cmd, #_status_cmd, #_stop_cmd, binder_methods, #chown_log_files, #config_binding, #config_file_path, #config_template_files, #configure_remote_dirs, #each_server_app, #exit_on_failure, #has_setup?, #log_file, #log_files, #pick_sudo, #register_after_user_script, #restart, short_name, #start, #status, #stop, underscore, #upload_config_files

Constructor Details

#initialize(app, options = {}) ⇒ Apache

Returns a new instance of Apache.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sunshine/daemons/apache.rb', line 14

def initialize app, options={}
  super

  @bin = options[:bin] || 'apache2ctl'

  @sigkill = 'WINCH'

  @supports_rack      = false
  @supports_passenger = true

  @connections = options[:connections] || 256

  @rails_base_uri = options[:rails_base_uri]

  @timeout = 1 if @timeout < 1

  @dep_name = options[:dep_name] ||
    use_passenger? ? 'passenger-apache' : 'apache2'
end

Instance Attribute Details

#rails_base_uriObject

Returns the value of attribute rails_base_uri.



12
13
14
# File 'lib/sunshine/daemons/apache.rb', line 12

def rails_base_uri
  @rails_base_uri
end

Instance Method Details

#setupObject



40
41
42
43
44
45
# File 'lib/sunshine/daemons/apache.rb', line 40

def setup
  super do |server_app, binder|
    binder.set :rails_base_uri, @rails_base_uri
    yield(server_app, binder) if block_given?
  end
end

#start_cmdObject



35
36
37
# File 'lib/sunshine/daemons/apache.rb', line 35

def start_cmd
  "#{@bin} -f #{self.config_file_path} -E #{log_file :stderr}"
end