36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/trident/cli.rb', line 36
def execute
if generate_config?
puts File.read(File.expand_path("../../../trident.example.yml", __FILE__))
exit(0)
end
procline "cli", "(initializing)"
self.logfile = expand_path(logfile)
self.pidfile = expand_path(pidfile)
self.config = expand_path(config)
Trident::CLILogger.trident_logger = Logger.new(logfile ? logfile : STDOUT)
Trident::CLILogger.trident_logger.level = verbose? ? Logger::DEBUG : Logger::INFO
$stdout.sync = $stderr.sync = true
if daemon? && (logfile.nil? || pidfile.nil?)
signal_usage_error "--logfile and --pidfile are required when running as a daemon"
end
logger.info "Loading config from: #{config}"
config_hash = load_config(config)
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
daemonize(logfile) if daemon?
File.write(pidfile, Process.pid.to_s) if pidfile
handlers = create_handlers(config_hash['handlers'])
pools = create_pools(config_hash['pools'], handlers, pool_list)
manager = Trident::PoolManager.new(config_hash['application'],
pools.values,
config_hash['prefork'] == true)
Trident::SignalHandler.start(config_hash['signals'], manager)
Trident::SignalHandler.join
end
|