Class: Nginx::Server
- Inherits:
-
Object
- Object
- Nginx::Server
- Defined in:
- lib/nginx/server.rb
Instance Method Summary collapse
- #access_log ⇒ Object
- #error_log ⇒ Object
-
#initialize(template, dir: "/tmp/nginx.#{Process.pid}.#{SecureRandom.uuid}") ⇒ Server
constructor
A new instance of Server.
- #pid ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(template, dir: "/tmp/nginx.#{Process.pid}.#{SecureRandom.uuid}") ⇒ Server
Returns a new instance of Server.
8 9 10 11 12 |
# File 'lib/nginx/server.rb', line 8 def initialize template, dir: "/tmp/nginx.#{Process.pid}.#{SecureRandom.uuid}" @dir = Pathname dir; @dir.mkpath create_config template end |
Instance Method Details
#access_log ⇒ Object
29 30 31 |
# File 'lib/nginx/server.rb', line 29 def access_log 'access.log' end |
#error_log ⇒ Object
25 26 27 |
# File 'lib/nginx/server.rb', line 25 def error_log 'error.log' end |
#pid ⇒ Object
33 34 35 |
# File 'lib/nginx/server.rb', line 33 def pid 'nginx.pid' end |
#start ⇒ Object
14 15 16 17 18 19 |
# File 'lib/nginx/server.rb', line 14 def start @nginx_pid = suppress_output do spawn "nginx -c nginx.conf -p #{@dir} -g 'daemon off;'" end; at_exit { stop } @nginx_pid end |
#stop ⇒ Object
21 22 23 |
# File 'lib/nginx/server.rb', line 21 def stop `kill #{@nginx_pid}` end |