Class: PhusionPassenger::Standalone::StartCommand

Inherits:
Command show all
Defined in:
lib/phusion_passenger/standalone/start_command.rb

Constant Summary

Constants inherited from Command

Command::DEFAULT_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

show_in_command_list

Constructor Details

#initialize(args) ⇒ StartCommand

Returns a new instance of StartCommand.



46
47
48
49
50
51
52
53
# File 'lib/phusion_passenger/standalone/start_command.rb', line 46

def initialize(args)
	super(args)
	@console_mutex = Mutex.new
	@termination_pipe = IO.pipe
	@threads = []
	@interruptable_threads = []
	@plugin = PhusionPassenger::Plugin.new('standalone/start_command', self, @options)
end

Class Method Details

.descriptionObject



42
43
44
# File 'lib/phusion_passenger/standalone/start_command.rb', line 42

def self.description
	return "Start Phusion Passenger Standalone."
end

Instance Method Details

#runObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/phusion_passenger/standalone/start_command.rb', line 55

def run
	parse_my_options
	sanity_check_options
	
	ensure_nginx_installed
	determine_various_resource_locations
	require_app_finder
	@app_finder = AppFinder.new(@args, @options)
	@apps = @app_finder.scan
	@plugin.call_hook(:found_apps, @apps)
	
	extra_controller_options = {}
	@plugin.call_hook(:before_creating_nginx_controller, extra_controller_options)
	create_nginx_controller(extra_controller_options)
	
	begin
		start_nginx
		show_intro_message
		daemonize if @options[:daemonize]
		Thread.abort_on_exception = true
		@plugin.call_hook(:nginx_started, @nginx)
		########################
		########################
		watch_log_files_in_background if should_watch_logs?
		wait_until_nginx_has_exited
	rescue Interrupt
		stop_threads
		stop_nginx
		exit 2
	rescue SignalException => signal
		stop_threads
		stop_nginx
		if signal.message == 'SIGINT' || signal.message == 'SIGTERM'
			exit 2
		else
			raise
		end
	rescue Exception => e
		stop_threads
		stop_nginx
		raise
	ensure
		stop_threads
	end
ensure
	if @temp_dir
		FileUtils.rm_rf(@temp_dir) rescue nil
	end
	@plugin.call_hook(:cleanup)
end