class Nginxtra::Actions::Start
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.
Public Instance Methods
compile()
click to toggle source
Invoke nginx compilation, to ensure it is up to date.
# File lib/nginxtra/actions/start.rb, line 24 def compile Nginxtra::Actions::Compile.new(@thor, @config).compile end
no_need_to_start()
click to toggle source
Notify the user that nginx is already started.
# File lib/nginxtra/actions/start.rb, line 41 def no_need_to_start @thor.say "nginx is already started" end
save_config_files()
click to toggle source
Save nginx config files to the proper config file path.
# 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?()
click to toggle source
Determine if we should even bother starting. This returns true if the user forced, or if nginx is already running.
# File lib/nginxtra/actions/start.rb, line 47 def should_start? return true if force? !Nginxtra::Config.nginx_running? end
start()
click to toggle source
First, ensure nginx has been compiled, then make sure configuration is correct, and finally start nginx and note the start time.
# 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()
click to toggle source
Start
nginx as a daemon, unless –no-daemon is provided.
# File lib/nginxtra/actions/start.rb, line 53 def start_nginx if @thor.options["daemon"] daemon :start else exec [Nginxtra::Config.nginx_executable, "nginx"] end end
update_last_start()
click to toggle source
Update the last nginx start time.
# File lib/nginxtra/actions/start.rb, line 62 def update_last_start Nginxtra::Status[:last_start_time] = Time.now end