52
53
54
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/phusion_passenger/standalone/start_command.rb', line 52
def run
parse_my_options
sanity_check_options
require 'phusion_passenger/standalone/runtime_locator'
@runtime_locator = RuntimeLocator.new(@options[:runtime_dir],
@options[:nginx_version])
ensure_runtime_installed
exit if @options[:runtime_check_only]
require_app_finder
@app_finder = AppFinder.new(@args, @options)
@apps = @app_finder.scan
@options = @app_finder.global_options
determine_various_resource_locations
@plugin.call_hook(:found_apps, @apps)
= {}
@plugin.call_hook(:before_creating_nginx_controller, )
create_nginx_controller()
begin
start_nginx
show_intro_message
if @options[:daemonize]
if PlatformInfo.ruby_supports_fork?
daemonize
else
daemonize_without_fork
end
end
Thread.abort_on_exception = true
@plugin.call_hook(:nginx_started, @nginx)
touch_temp_dir_in_background
watch_log_files_in_background if should_watch_logs?
wait_until_nginx_has_exited if should_wait_until_nginx_has_exited?
rescue Interrupt
begin_shutdown
stop_threads
stop_nginx
exit 2
rescue SignalException => signal
begin_shutdown
stop_threads
stop_nginx
if signal.message == 'SIGINT' || signal.message == 'SIGTERM'
exit 2
else
raise
end
rescue Exception => e
begin_shutdown
stop_threads
stop_nginx
raise
ensure
begin_shutdown
begin
stop_threads
ensure
finalize_shutdown
end
end
ensure
@plugin.call_hook(:cleanup)
end
|