From: jiil.hyoun Date: Thu, 6 Dec 2012 03:25:51 +0000 (+0900) Subject: [Title] db can modify port information X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5de8b905a6bad1d783985cbad62932a558765c2f;p=sdk%2Ftools%2Fsdk-build.git [Title] db can modify port information [Type] Enhancement [Module] Toolchain / [Priority] Minor [Jira#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] Change-Id: I627c20c94e3e8b1168d5ac8d0aa15af789a2e9fa --- diff --git a/src/build_server/BuildServer.rb b/src/build_server/BuildServer.rb index fd5e28d..bcf5893 100644 --- a/src/build_server/BuildServer.rb +++ b/src/build_server/BuildServer.rb @@ -40,7 +40,7 @@ require "ProjectManager.rb" 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 @@ -70,8 +70,6 @@ class BuildServer @remote_servers = [] @req_listener = [] @finish = false - # port number - @port = 2222 # status @status = "RUNNING" # host_os @@ -184,6 +182,20 @@ class BuildServer 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 @@ -195,15 +207,8 @@ class BuildServer 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 @@ -620,7 +625,7 @@ class BuildServer 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')"