NEW_VER_PATH = BACKUP_ROOT + "/new_ver"
UPGRADE_CMD = "#{PREV_VER_PATH}/upgrade"
BUILD_CONFIG_ROOT = "#{Utils::HOME}/.build_tools/build_server/#{svr_name}"
- BUILD_FRIENDS_FILE = "#{BUILD_CONFIG_ROOT}/friends"
if not File.exist? BACKUP_ROOT then FileUtils.mkdir_p(BACKUP_ROOT) end
log = PackageServerLog.new( "#{BACKUP_ROOT}/log" )
# Execute start command
if start_opt
- if svr_type.eql? "BUILDSERVER" then
+ if not build_server.nil? and svr_type.eql? "BUILDSERVER" then
# get friends server information
- if File.exist? BUILD_FRIENDS_FILE then
- File.open( BUILD_FRIENDS_FILE, "r" ) do |f|
- f.each_line do |l|
- if l.split(",").count < 2 then
- next
- end
-
- ip = l.split(",")[0].strip
- port = l.split(",")[1].strip
-
- build_client = BuildCommClient.create( ip, port )
- if build_client.nil? then
- log.info("Friend Server #{ip}:#{port} is not running!", Log::LV_USER)
- next
- end
+ build_server.friend_servers.each do |svr|
+ ip = svr.ip
+ port = svr.port
+
+ build_client = BuildCommClient.create( ip, port )
+ if build_client.nil? then
+ log.info("Friend Server #{ip}:#{port} is not running!", Log::LV_USER)
+ next
+ end
- # send request
- if build_client.send "UPGRADE|#{build_server.password}" then
- # recevie & print
- mismatched = false
- result = build_client.read_lines do |l|
- log.error(l, Log::LV_USER)
- if l.include? "Password mismatched!" then
- mismatched = true
- end
- end
-=begin
- if result and not mismatched then
- log.info("Friend Server #{ip}:#{port} upgrade failed!", Log::LV_USER)
- else
- log.info("Friend Server #{ip}:#{port} upgrade requested!", Log::LV_USER)
- end
-=end
+ # send request
+ log.info("Upgrading Friend Server #{ip}:#{port}...", Log::LV_USER)
+ if build_client.send "UPGRADE|#{build_server.password}" then
+ # recevie & print
+ mismatched = false
+ result = build_client.read_lines do |l|
+ log.error(l, Log::LV_USER)
+ if l.include? "Password mismatched!" then
+ mismatched = true
end
-
- # terminate
- build_client.terminate
end
end
- else
- log.info("No Friend Server.", Log::LV_USER)
- end
+
+ # terminate
+ build_client.terminate
+ end
# Start Build server
cmd = Utils.generate_shell_command("#{dibs_path}/build-svr start -n #{svr_name} -p #{svr_port}")