2 # STDERR.puts "Trapped SIGHUP"
8 # STDERR.puts "Trapped SIGINT"
14 # STDERR.puts "Trapped SIGTERM"
19 STDERR.puts
"Started #{Process.pid}"
38 STDERR.puts
"Started bootloader for #{@host} at: #{Time.now}"
42 class Discourse
::Config
43 def initialize(config
, discourse_root
=nil)
44 @config = YAML
.load_file(config
)
45 @discourse_root = discourse_root
|| "/var/www/discourse"
51 ensure_database_config
56 @config["env"].each
do |k
,v
|
61 def ensure_database_config
62 current
= YAML
.load_file("#{@discourse_root}/config/database.yml.production-sample")
63 current
= current
.merge(@config["databases"])
64 File
.open("#{@discourse_root}/config/database.yml", "w"){|f
| f
.write current
.to_yaml
}
67 def ensure_git_version
68 STDERR.puts
`cd #{@discourse_root} && git pull`
72 @config["roles"].each
do |role
|
81 STDERR.puts
`cd #{@discourse_root} && RAILS_ENV=production bundle exec rake db:migrate`
86 class Discourse
::Process
92 pid
= Process
.spawn(*args
)
93 STDERR.puts
"Spawned #{args.inspect} pid: #{pid}"
105 self.class.spawn(*args
)
109 # STDERR.puts "Trapped SIGHUP"
113 # STDERR.puts "Trapped SIGINT"
117 # STDERR.puts "Trapped SIGTERM"
118 # pids.dup.each do |pid|
119 # STDERR.puts "Sending TERM to #{pid}"
121 # Process.kill("TERM", pid) rescue nil
124 # pids.dup.each do |pid|
126 # Process.wait(pid) rescue nil
129 # STDERR.puts "Exiting"
134 class Discourse
::Postgres
135 attr_accessor
:data_dir
140 class Discourse
::Sshd < Discourse
::Process
142 # we need this dir to run sshd
143 `mkdir /var/run/sshd` unless File
.directory
? "/var/run/sshd"
144 spawn("/usr/sbin/sshd")
148 # tmp = "/home/sam/Source/discourse_docker/shared/config/web1/conf.yml"
149 tmp
= "/shared/config/web1/conf.yml"
150 conf
= Discourse
::Config.new(tmp
)
154 #Discourse::Sshd.new.start