lib/nginxtra/actions/start.rb in nginxtra-1.0.15.0 vs lib/nginxtra/actions/start.rb in nginxtra-1.2.0.1
- old
+ new
@@ -8,12 +8,16 @@
# First, ensure nginx has been compiled, then make sure
# configuration is correct, and finally start nginx and note the
# start time.
def start
- compile
- install
+ without_force do
+ compile
+ install
+ end
+
+ return no_need_to_start unless should_start?
save_config_files
start_nginx
update_last_start
end
@@ -35,9 +39,21 @@
@thor.inside Nginxtra::Config.config_dir do
files.each do |filename|
@thor.create_file filename, @config.file_contents(filename), :force => true
end
end
+ end
+
+ # Notify the user that nginx is already started.
+ def no_need_to_start
+ @thor.say "nginx is already started"
+ end
+
+ # Determine if we should even bother starting. This returns
+ # true if the user forced, or if nginx is already running.
+ def should_start?
+ return true if force?
+ !Nginxtra::Config.nginx_running?
end
# Start nginx as a daemon.
def start_nginx
daemon :start