Class: Nginxtra::Actions::Start
- Inherits:
-
Object
- Object
- Nginxtra::Actions::Start
- Includes:
- Nginxtra::Action
- Defined in:
- lib/nginxtra/actions/start.rb
Overview
The Nginxtra::Actions::Compile class encapsulates starting nginx with the specified configuration file. It also makes sure that nginx has been compiled with the correct options.
Instance Method Summary collapse
-
#compile ⇒ Object
Invoke nginx compilation, to ensure it is up to date.
-
#no_need_to_start ⇒ Object
Notify the user that nginx is already started.
-
#save_config_files ⇒ Object
Save nginx config files to the proper config file path.
-
#should_start? ⇒ Boolean
Determine if we should even bother starting.
-
#start ⇒ Object
First, ensure nginx has been compiled, then make sure configuration is correct, and finally start nginx and note the start time.
-
#start_nginx ⇒ Object
Start nginx as a daemon, unless –no-daemon is provided.
-
#update_last_start ⇒ Object
Update the last nginx start time.
Methods included from Nginxtra::Action
Instance Method Details
#compile ⇒ Object
Invoke nginx compilation, to ensure it is up to date.
24 25 26 |
# File 'lib/nginxtra/actions/start.rb', line 24 def compile Nginxtra::Actions::Compile.new(@thor, @config).compile end |
#no_need_to_start ⇒ Object
Notify the user that nginx is already started.
41 42 43 |
# File 'lib/nginxtra/actions/start.rb', line 41 def no_need_to_start @thor.say "nginx is already started" end |
#save_config_files ⇒ Object
Save nginx config files to the proper config file path.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nginxtra/actions/start.rb', line 29 def save_config_files files = @config.files raise Nginxtra::Error::MissingNginxConfig unless files.include? "nginx.conf" @thor.inside Nginxtra::Config.config_dir do files.each do |filename| @thor.create_file filename, @config.file_contents(filename), force: true end end end |
#should_start? ⇒ Boolean
Determine if we should even bother starting. This returns true if the user forced, or if nginx is already running.
47 48 49 50 |
# File 'lib/nginxtra/actions/start.rb', line 47 def should_start? return true if force? !Nginxtra::Config.nginx_running? end |
#start ⇒ Object
First, ensure nginx has been compiled, then make sure configuration is correct, and finally start nginx and note the start time.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nginxtra/actions/start.rb', line 12 def start without_force do compile end return no_need_to_start unless should_start? save_config_files start_nginx update_last_start end |
#start_nginx ⇒ Object
Start nginx as a daemon, unless –no-daemon is provided.
53 54 55 56 57 58 59 |
# File 'lib/nginxtra/actions/start.rb', line 53 def start_nginx if @thor.["daemon"] daemon :start else exec [Nginxtra::Config.nginx_executable, "nginx"] end end |