blob: b22e8e5c37cf41666873ec0295d61b258f9981e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
|
require 'yaml'
config_file = File.join(ENV['HOME'], '.opentox/config.yaml')
if File.exist?(config_file)
config = YAML.load_file(config_file)
else
FileUtils.mkdir_p File.dirname(config_file)
FileUtils.cp(File.join(File.dirname(__FILE__), 'templates/config.yaml'), config_file)
puts "Please edit #{config_file} and restart your application."
exit
end
puts config
@environment = "development" unless @environment = ENV['OPENTOX']
@config = config[@environment]
port = 5000
@services = {}
begin
`killall thin` if @environment == "development"
rescue
end
config["services"].each do |service|
dir = File.join(@config["base_dir"], service)
case @environment
when "development|test"
@services[dir] = "http://localhost:#{port}/"
Dir.chdir dir
`thin --debug --rackup config.ru start -p #{port} -e #{@environment} &`
#pid = fork {`urxvt -title #{service} -e thin --debug --rackup config.ru start -p #{port} -e development`}
#Process.detach(pid)
port += 1
when "production"
@services[dir] = "http://#{@config['base_uri']}/#{service}/v#{major_version}/"
`touch #{File.join(dir,"tmp/restart.txt")}`
else
"Puts environment #{ENV['OPENTOX']} not supported."
end
end
def major_version
File.open(File.join(File.dirname(__FILE__), '../VERSION')).each_line.first.split(/\./)[0]
end
|