Class: Nginxtra::Actions::Stop

Inherits:
Object
  • Object
show all
Includes:
Nginxtra::Action
Defined in:
lib/nginxtra/actions/stop.rb

Overview

The Nginxtra::Actions::Stop class encapsulates stopping nginx.

Instance Method Summary collapse

Methods included from Nginxtra::Action

#daemon, #initialize

Instance Method Details

#no_need_to_stopObject



14
15
16
# File 'lib/nginxtra/actions/stop.rb', line 14

def no_need_to_stop
  @thor.say "nginx is already stopped"
end

#should_stop?Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/nginxtra/actions/stop.rb', line 18

def should_stop?
  return true if force?
  Nginxtra::Config.nginx_running?
end

#stopObject

Stop nginx and note the new last stop time.



8
9
10
11
12
# File 'lib/nginxtra/actions/stop.rb', line 8

def stop
  return no_need_to_stop unless should_stop?
  stop_nginx
  update_last_stop
end

#stop_nginxObject



23
24
25
# File 'lib/nginxtra/actions/stop.rb', line 23

def stop_nginx
  daemon :stop
end

#update_last_stopObject



27
28
29
# File 'lib/nginxtra/actions/stop.rb', line 27

def update_last_stop
  Nginxtra::Status[:last_stop_time] = Time.now
end