class Guard::Nginx
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/guard/nginx.rb, line 9 def initialize(options) UI.info "hello path: #{Dir.pwd}" Dir.mkdir("#{tmp_path}/config") unless Dir.exist?("#{tmp_path}/config") super end
Public Instance Methods
reload()
click to toggle source
# File lib/guard/nginx.rb, line 34 def reload UI.info 'reload' if pid generate_config UI.info "Sending HUP signal to Nginx (reloading #{pid})" ::Process.kill('HUP', pid) true end end
run_all()
click to toggle source
# File lib/guard/nginx.rb, line 45 def run_all reload end
run_on_change(_paths)
click to toggle source
# File lib/guard/nginx.rb, line 49 def run_on_change(_paths) true end
start()
click to toggle source
# File lib/guard/nginx.rb, line 15 def start # ensure config - create tmp file UI.info "Starting Nginx on port #{port}" generate_config IO.popen("#{executable} -c #{tmp_path}/config/nginx.conf", 'w+') UI.info 'Nginx started' if $CHILD_STATUS.success? end
stop()
click to toggle source
# File lib/guard/nginx.rb, line 24 def stop puts pid if pid UI.info "Sending TERM signal to Nginx (#{pid})" FileUtils.rm "#{tmp_path}/config/nginx.conf" ::Process.kill('TERM', pid) true end end
Private Instance Methods
executable()
click to toggle source
# File lib/guard/nginx.rb, line 90 def executable options.fetch(:executable) { 'nginx' } end
generate_config()
click to toggle source
# File lib/guard/nginx.rb, line 65 def generate_config UI.info 'Generating Nginx Config' file = ERB.new( File.read( File.expand_path('nginx/templates/nginx_config.erb', File.dirname(__FILE__)) ), nil, '-' ).result( ConfigProcessor.new({ port: port, use_ssl: true, http_port: 3000, https_port: 3001, server_name: 'localhost' }).get_binding ) File.open("#{tmp_path}/config/nginx.conf", 'w') { |f| f.write(file) } end
pid()
click to toggle source
# File lib/guard/nginx.rb, line 86 def pid File.exist?(pidfile_path) && File.read(pidfile_path).to_i end
pidfile_path()
click to toggle source
# File lib/guard/nginx.rb, line 55 def pidfile_path options.fetch(:pidfile) do File.expand_path('tmp/pids/nginx.pid', Dir.pwd) end end
port()
click to toggle source
# File lib/guard/nginx.rb, line 94 def port options.fetch(:port) { 3000 } end
tmp_path()
click to toggle source
# File lib/guard/nginx.rb, line 61 def tmp_path File.expand_path('tmp', Dir.pwd) end