QUERY_SYSTEM="build-cli query-system -d <server address>"
QUERY_PROJECT="build-cli query-project -d <server address>"
QUERY_JOB="build-cli query-job -d <server address>"
- CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>]"
+ CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>] [-U user-email]"
REGISTER="build-cli register -P <package file> -d <server address> [-t <ftp server url>] [-w <password>] [-D <distribution name>] [-U user-email]"
end
@remote_servers = get_remote_servers()
@remote_servers.each do |server|
# update state
- server.update_state
+ get_db_connection() do |db|
+ server.update_state(db)
+ end
end
# handle jobs
description VARCHAR(255),
CONSTRAINT fk_sync_pkg_servers_distributions1 FOREIGN KEY ( distribution_id ) REFERENCES distributions ( id ) ) #{post_fix}"
- RemoteBuildServer.create_table(db, inc, post_fix)
-
db.do "CREATE TABLE supported_os (
id INTEGER PRIMARY KEY #{inc},
os_category_id INTEGER NOT NULL,
name VARCHAR(32) NOT NULL UNIQUE,
CONSTRAINT fk_supported_os_os_category1 FOREIGN KEY ( os_category_id ) REFERENCES os_category ( id ) ) #{post_fix}"
+ RemoteBuildServer.create_table(db, inc, post_fix)
+
# USERS/GROUPS
# users
db.do "CREATE TABLE users ( id INTEGER PRIMARY KEY #{inc}, name VARCHAR(32) NOT NULL UNIQUE, email VARCHAR(256), password_hash VARCHAR(256), password_salt VARCHAR(256) ) #{post_fix}"
# query remote server info & update server state
- def update_state
+ def update_state(db)
# send
#@status = "DISCONNECTED"
@status = "DISCONNECTED"
end
client.terminate
- if @status == "DISCONNECTED" then return end
+ if @status == "DISCONNECTED" then
+ db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
+ return
+ end
# send
@working_jobs = []
@status = "DISCONNECTED"
end
client.terminate
+ if @status == "DISCONNECTED" then
+ db.do "UPDATE remote_build_servers SET status = 'DISCONNECTED', max_job_count = 0, working_job_count = 0, waiting_job_count = 0 WHERE id = #{@id}"
+ else
+ db.do "UPDATE remote_build_servers SET
+ status = '#{@status}',
+ supported_os_id = (SELECT supported_os.id FROM supported_os_id WHERE supported_os.name = '#{@host_os}'),
+ max_job_count = #{@max_working_jobs},
+ working_job_count = #{@working_jobs.count},
+ waiting_job_count = #{@waiting_jobs.count} WHERE id = #{@id}"
+ end
end
db.do "CREATE TABLE remote_build_servers (
id INTEGER PRIMARY KEY #{inc},
svr_addr VARCHAR(64) NOT NULL UNIQUE,
- description VARCHAR(256) )#{post_fix}"
+ description VARCHAR(256),
+ status VARCHAR(32),
+ supported_os_id INTEGER,
+ max_job_count INTEGER,
+ working_job_count INTEGER,
+ waiting_job_count INTEGER,
+ CONSTRAINT fk_remote_build_servers_supported_os1 FOREIGN KEY ( supported_os_id ) REFERENCES supported_os ( id ) )#{post_fix}"
end
def self.load_row(row)
svr_ip,svr_port=row['svr_addr'].strip.split(":")
new_obj = new(svr_ip, svr_port, row['description'] )
- new_obj.set_id( row['id'] )
+ new_obj.set_id( row['id'] )
return new_obj
end