[Title] db can modify port information
authorjiil.hyoun <jiil.hyoun@samsung.com>
Thu, 6 Dec 2012 03:25:51 +0000 (12:25 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Thu, 6 Dec 2012 03:25:51 +0000 (12:25 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I627c20c94e3e8b1168d5ac8d0aa15af789a2e9fa

src/build_server/BuildServer.rb

index fd5e28d38713178fba89da1dbdf87c25a833c532..bcf5893add5f08d2f9561c75598ab8ac16972381 100644 (file)
@@ -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')"