From a2b0554bb00da9e2f8d657aa195bed1b85be3805 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Tue, 29 Oct 2013 23:17:34 -0700 Subject: [PATCH] launcher maps more stuff, bootloader gone --- .gitignore | 3 + launcher | 3 +- shared/bootloader.rb | 155 ------------------------------------------- 3 files changed, 4 insertions(+), 157 deletions(-) create mode 100644 .gitignore delete mode 100644 shared/bootloader.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b199b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +shared/pups +*.swp +cids/* diff --git a/launcher b/launcher index 27cfc4e..7927227 100755 --- a/launcher +++ b/launcher @@ -70,8 +70,7 @@ if [ "$command" == "start" ] if [ ! -e $cidfile ] then echo "No cid found, creating a new container" -#docker run -cidfile $cidfile -p 22 -d -v `pwd`/shared:/shared samsaffron/discourse /usr/local/bin/ruby /shared/bootloader.rb - docker run -d samsaffron/discourse /usr/local/bin/ruby -e 'sleep 100' + docker run -cidfile $cidfile -p 22 -p 3000 -d -v `pwd`/shared:/shared samsaffron/discourse /shared/pups/bin/pups /$config_file exit 0 else echo "cid found, ensuring container is started" diff --git a/shared/bootloader.rb b/shared/bootloader.rb deleted file mode 100644 index eed2688..0000000 --- a/shared/bootloader.rb +++ /dev/null @@ -1,155 +0,0 @@ -# trap "SIGHUP" do -# STDERR.puts "Trapped SIGHUP" -# STDERR.flush -# exit -# end -# -# trap "SIGINT" do -# STDERR.puts "Trapped SIGINT" -# STDERR.flush -# exit -# end -# -# trap "SIGTERM" do -# STDERR.puts "Trapped SIGTERM" -# STDERR.flush -# exit -# end - -STDERR.puts "Started #{Process.pid}" -STDERR.puts `ps aux` - -while true - gets - STDERR.puts "HERE" - sleep 1 -end - -STDERR.puts "HERE" - -exit - -require 'yaml' -require 'open3' -require 'readline' - -@host = ARGV[0] - -STDERR.puts "Started bootloader for #{@host} at: #{Time.now}" - -module Discourse; end - -class Discourse::Config - def initialize(config, discourse_root=nil) - @config = YAML.load_file(config) - @discourse_root = discourse_root || "/var/www/discourse" - end - - def startup - load_env - ensure_git_version - ensure_database_config - start_roles - end - - def load_env - @config["env"].each do |k,v| - ENV[k.to_s] = v.to_s - end if @config["env"] - end - - def ensure_database_config - current = YAML.load_file("#{@discourse_root}/config/database.yml.production-sample") - current = current.merge(@config["databases"]) - File.open("#{@discourse_root}/config/database.yml", "w"){|f| f.write current.to_yaml } - end - - def ensure_git_version - STDERR.puts `cd #{@discourse_root} && git pull` - end - - def start_roles - @config["roles"].each do |role| - case role - when "unicorn" - start_unicorn - end - end - end - - def start_unicorn - STDERR.puts `cd #{@discourse_root} && RAILS_ENV=production bundle exec rake db:migrate` - end - -end - -class Discourse::Process - def self.pids - @@pids ||= [] - end - - def self.spawn(*args) - pid = Process.spawn(*args) - STDERR.puts "Spawned #{args.inspect} pid: #{pid}" - pids << pid - - Thread.start do - Process.wait(pid) - pids.delete(pid) - end - - pid - end - - def spawn(*args) - self.class.spawn(*args) - end - - # trap "HUP" do - # STDERR.puts "Trapped SIGHUP" - # end - - # trap "INT" do - # STDERR.puts "Trapped SIGINT" - # end - - # trap "TERM" do - # STDERR.puts "Trapped SIGTERM" - # pids.dup.each do |pid| - # STDERR.puts "Sending TERM to #{pid}" - # # no such process - # Process.kill("TERM", pid) rescue nil - # end - - # pids.dup.each do |pid| - # # no such process - # Process.wait(pid) rescue nil - # end - - # STDERR.puts "Exiting" - # exit 1 - # end -end - -class Discourse::Postgres - attr_accessor :data_dir - def start - end -end - -class Discourse::Sshd < Discourse::Process - def start - # we need this dir to run sshd - `mkdir /var/run/sshd` unless File.directory? "/var/run/sshd" - spawn("/usr/sbin/sshd") - end -end - -# tmp = "/home/sam/Source/discourse_docker/shared/config/web1/conf.yml" -tmp = "/shared/config/web1/conf.yml" -conf = Discourse::Config.new(tmp) -#conf.startup - - -#Discourse::Sshd.new.start - -- 2.25.1