Skip to content

Commit

Permalink
basic syntax checking and reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Burke Libbey committed Apr 19, 2009
1 parent 3b8e5a3 commit ae4b62c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/servers/apache.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module ApacheServer
def config_ok?
def self.config_ok?
system("apachectl -t")
end
def reload
def self.reload
system("apachectl graceful")
end
end
4 changes: 2 additions & 2 deletions lib/servers/nginx.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module NginxServer
def config_ok?
def self.config_ok?
system("nginx -t")
end
def reload
def self.reload
puts "*** WON'T RELOAD NGINX UNTIL PASSENGER FIXES `kill -HUP` ISSUE. RESTART MANUALLY. ***"
return false
end
Expand Down
28 changes: 25 additions & 3 deletions webconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ module Webconfig

end

def self.test_and_load_config(server)
srv_mod_name = "#{server.capitalize}Server"
unless Object.const_defined?(srv_mod_name)
begin
require "servers/#{server}"
rescue LoadError
puts "*** DON'T KNOW HOW TO CHECK AND LOAD SERVER: #{server} ***"
puts " ** YOU'LL HAVE TO RESTART IT MANUALLY."
return
end
end
srv_mod = Object.const_get(srv_mod_name)
unless srv_mod::config_ok?
puts "*** CONFIG CHECK FAILED FOR SERVER: #{server} ***"
else
unless srv_mod::reload
puts "*** RELOAD SEEMS TO HAVE FAILED FOR SERVER #{server}. ***"
end
end
end

class Domain

def initialize(args)
Expand Down Expand Up @@ -87,10 +108,11 @@ if __FILE__ == $0
config = Webconfig.config_by_server

# Write out a file in ./gen for each server configured.
config.each do |k,v|
File.open("#{Webconfig::WEBCONFIG_PATH}/gen/#{k}.gen.conf",'w') do |f|
f.puts v
config.each do |server, config|
File.open("#{Webconfig::WEBCONFIG_PATH}/gen/#{server}.gen.conf",'w') do |f|
f.puts config
end
Webconfig.test_and_load_config(server)
end

puts "[success]"
Expand Down

0 comments on commit ae4b62c

Please sign in to comment.