Class: Cloudkeeper::Nginx::HttpServer
- Inherits:
-
Object
- Object
- Cloudkeeper::Nginx::HttpServer
- Defined in:
- lib/cloudkeeper/nginx/http_server.rb
Instance Attribute Summary collapse
-
#access_data ⇒ Object
readonly
Returns the value of attribute access_data.
-
#auth_file ⇒ Object
readonly
Returns the value of attribute auth_file.
-
#conf_file ⇒ Object
readonly
Returns the value of attribute conf_file.
Instance Method Summary collapse
-
#initialize ⇒ HttpServer
constructor
A new instance of HttpServer.
- #start(image_file) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ HttpServer
Returns a new instance of HttpServer.
13 14 15 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 13 def initialize @access_data = {} end |
Instance Attribute Details
#access_data ⇒ Object (readonly)
Returns the value of attribute access_data.
11 12 13 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 11 def access_data @access_data end |
#auth_file ⇒ Object (readonly)
Returns the value of attribute auth_file.
11 12 13 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 11 def auth_file @auth_file end |
#conf_file ⇒ Object (readonly)
Returns the value of attribute conf_file.
11 12 13 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 11 def conf_file @conf_file end |
Instance Method Details
#start(image_file) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 17 def start(image_file) logger.debug 'Starting NGINX server' @access_data = {} credentials = prepare_credentials configuration = prepare_configuration File.dirname(image_file), File.basename(image_file) prepare_configuration_file configuration fill_access_data credentials, configuration Cloudkeeper::CommandExecutioner.execute Cloudkeeper::Settings[:'nginx-binary'], '-c', conf_file.path, '-p', Cloudkeeper::Settings[:'nginx-runtime-dir'] rescue Cloudkeeper::Errors::CommandExecutionError, ::IOError => ex stop raise Cloudkeeper::Errors::NginxError, ex end |
#stop ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cloudkeeper/nginx/http_server.rb', line 33 def stop logger.debug 'Stopping NGINX server' if conf_file Cloudkeeper::CommandExecutioner.execute Cloudkeeper::Settings[:'nginx-binary'], '-s', 'stop', '-c', conf_file.path, '-p', Cloudkeeper::Settings[:'nginx-runtime-dir'] conf_file.unlink end auth_file.unlink if auth_file @access_data = {} rescue Cloudkeeper::Errors::CommandExecutionError, ::IOError => ex raise Cloudkeeper::Errors::NginxError, ex end |