15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/jettr/command.rb', line 15
def start(path=".")
config = nil
config_file = File.join(path,"jettr.yaml")
if File.exist?(config_file)
config = Jettr::Config.new(:config_file => config_file)
else
config = Jettr::Config.new({
:server => {
:port => options[:port]
},
:apps => [
{
:type => options[:type],
:app_path => path,
:app_uri => options[:uri]
}
]
})
end
if(options[:daemon])
d = Jettr::Akuma::Daemon.new
pid_file = File.expand_path(options[:pid] || File.join(path,'tmp','run',"jettr.pid"))
if(d.daemonized?)
if File.exist?(pid_file)
puts "Pid file alread exists at: #{pid_file}"
puts "run `jettr stop #{pid_file}` to ensure the process has been stopped."
exit 1
end
FileUtils.mkdir_p File.dirname(pid_file)
puts "PID File: #{pid_file}"
d.init(pid_file)
else
d.daemonize()
exit 0
end
end
server = config.create_server
puts "Starting Server..."
server.start
end
|