require "DistributionManager.rb"
class BuildServer
- attr_accessor :id, :path, :port, :status, :host_os, :log
+ attr_accessor :id, :path, :status, :host_os, :log
attr_accessor :remote_servers
attr_accessor :git_server_url, :git_bin_path
attr_accessor :allowed_git_branch
@remote_servers = []
@req_listener = []
@finish = false
- # port number
- @port = 2222
# status
@status = "RUNNING"
# host_os
end
end
+ def port
+ result = nil
+ get_db_connection() do |db|
+ result = db.select_one("SELECT value FROM server_configs WHERE property = 'port'")[0]
+ end
+ return (result.nil?) ? "" : result
+ end
+
+ def port=(svr_port)
+ get_db_connection() do |db|
+ db.do "UPDATE server_configs SET value = '#{svr_port}' WHERE property = 'port'"
+ end
+ end
+
def db_inc
return (@db_dsn =~ /^Mysql/i) ? "AUTO_INCREMENT" : "AUTOINCREMENT"
end
def db_now
return (@db_dsn =~ /^Mysql/i) ? "NOW()" : "datetime('now')"
end
-
- def save_port
- get_db_connection() do |db|
- db.do "UPDATE server_configs SET value = '#{@port}' WHERE property = 'port'"
- end
- end
# start server daemon
def start
- save_port
# set build cache dir
@build_cache_dir="#{BuildServer::CONFIG_ROOT}/#{@id}/build_cache"
if not File.exist? @build_cache_dir then
db.do "INSERT INTO server_configs (property,value) VALUES ('id','#{@id}')"
db.do "INSERT INTO server_configs (property,value) VALUES ('path','#{@path}')"
db.do "INSERT INTO server_configs (property,value) VALUES ('db_version','#{@db_version}')"
- db.do "INSERT INTO server_configs (property,value) VALUES ('port','#{@port}')"
+ db.do "INSERT INTO server_configs (property,value) VALUES ('port','2222')"
db.do "INSERT INTO server_configs (property,value) VALUES ('max_working_jobs','2')"
db.do "INSERT INTO server_configs (property,value) VALUES ('send_mail','NO')"
db.do "INSERT INTO server_configs (property,value) VALUES ('keep_time','86400')"