client.terminate
rescue => e
puts "ERROR: #{e}"
- client.terminate
+ if not client.terminated? then
+ client.terminate
+ end
+ exit 1
end
# Query log in case sync
client.terminate
rescue => e
puts "ERROR: #{e}"
- client.terminate
+ result = false
+ if not client.terminated? then
+ client.terminate
+ end
end
end
next
end
# print log
- puts line
+ log.puts line
+ end
+
+ if not output.nil? then
+ log.puts "=LOG_END"
end
if not result then
# Get log file infomation
server_id = Server_config.find(:first, :conditions => ["property = \"id\""])
- path = File.join(Utils::DIBS_WEB_CONFIG_PATH, server_id.value, "#{id}.log")
+ svr_dir = File.join(Utils::DIBS_WEB_CONFIG_PATH, server_id.value)
+ log_dir = File.join(svr_dir, "log")
+ path = File.join(log_dir, "#{id}.log")
time = Time.new
timestamp = time.getlocal
-
+
+ #check svr dir
+ if not File.exist?(svr_dir) then
+ render :text => e.message, :status => 406
+ return
+ end
+
+ #check log dir
+ if not File.exist?(log_dir) then
+ FileUtils.mkdir_p(log_dir)
+ end
+
#check file exist
if not File.exist?(path) then
#if file does not exist then execute query-log command
- Utils.sbi_query_log_command(id)
+ Utils.sbi_query_log_command(id, path)
conti = 1
else
start_line = line
if start_line < end_line
IO.popen("sed -n \"#{start_line},#{last_line}p\" #{path}") do |sed|
log_contents = sed.read
- end
- else
- last_line_content = IO.readlines(path)[-1]
- puts "!!!!!!!!!!!!!!!!!!"
- puts path
-
-
- puts IO.readlines(path)
- puts "!!!!!!!!!!!!!!!!!!"
- if last_line_content.start_with?("=STATUS,") then
- if start_line = 1 then log_contents = [last_line_content] end
- conti = 0
- elsif job.status.eql? "FINISHED" or job.status.eql? "CANCELED" or job.status.eql? "ERROR" then
- if start_line = 1 then log_contents = [last_line_content] end
- conti = 0
+ if log_contents.include? "=LOG_END" then
+ conti = 0
+ end
end
end
end
return execute_shell_return(cmd)
end
- def Utils.sbi_query_log_command(job_id)
+ def Utils.sbi_query_log_command(job_id, path)
dibs_web_config_path = File.join(Utils::HOME,".build_tools","web_server")
dibs_config = Server_config.find(:first, :conditions => ["property = \"port\""])
if dibs_config.nil?
dibs_address = BUILD_SERVER_ADDRESS + ":" + dibs_config.value
end
- dibs_config = Server_config.find(:first, :conditions => ["property = \"id\""])
- if dibs_config.nil?
- raise RuntimeError, "Can't find build server id"
- else
- path = File.join(dibs_web_config_path, dibs_config.value, "#{job_id}.log")
- end
-
if job_id.nil? or path.nil? then
raise RuntimeError, "Invalid query command id : #{job_id} path : #{path}"
end
options = options + " --output #{path}"
cmd = "#{DIBS_PATH}/build-cli query-log #{options}"
+puts "Query-log command"
+puts "[[[#{cmd}]]]"
fork do
exec(cmd)
$('.projects-project-list-collapsible').collapsible();
$('.projects-project-list-listview').listview();
-
});
}
h2.innerHTML = '<span class="alignleft">'+name+'</span><span class="alignright">'+type+'</span>';
div.appendChild(h2);
+ var testDiv = document.createElement('div');
+ //testDiv.innerHTML = '<label><input type="checkbox" name="checkbox-mini-0" class="custom" data-mini="true" />Build</label>';
+ testDiv.innerHTML = '<div data-role="fieldcontain"><fieldset data-role="controlgroup" data-type="horizontal"><legend>Font styling:</legend><input type="checkbox" name="checkbox-6" id="checkbox-6" class="custom" /><label for="checkbox-6">b</label></fieldset></div>';
+ h2.appendChild(testDiv);
+ $('#checkbox-6').checkboxradio();
+
var infoLine = document.createElement('p');
infoLine.setAttribute('style', 'font-size: 12px');
infoLine.innerHTML = "Maintainer : "+maintainer+"<br><br>";
end
def db_insert_id(db)
- return (@db_dsn =~ /^Mysql/i) ? db.func(:insert_id) : db.select_one("SELECT last_insert_rowid()")[0]
+ return (@db_dsn =~ /^Mysql/i) ? db.func(:insert_id).to_s : db.select_one("SELECT last_insert_rowid()")[0]
end
# start server daemon
job = nil
(@jobmgr.jobs + @jobmgr.internal_jobs + @jobmgr.reverse_build_jobs).each do |manager_job|
- if manager_job.id.eql? job_number.to_i then
+ if manager_job.id.eql? job_number then
job = manager_job
end
end
# send log file information using file-tail
log.tail { |line|
if line.strip.empty? then next end
- contents = line.sub(/^[a-zA-Z], \[.*\][ \t]*/,"")
- BuildCommServer.send(conn, contents)
+ BuildCommServer.send(conn, line)
# if read file's last line and job status ended then log file sending done
if log.eof? and (job.nil? or
rescue => e
@log.error e.message
@log.error e.backtrace.inspect
+ if e.message.eql? "Connection is closed" then
+ BuildCommServer.disconnect(conn)
+ Thread.exit
+ end
end
else
@log.error "Can't find job log file : #{job_log_path}"
@second_out = nil
end
- def job_status(status, msg)
- if msg.nil? then
- BuildCommServer.send( @second_out, "=JOB_STATUS,#{status}")
- else
- BuildCommServer.send( @second_out, "=JOB_STATUS,#{status},#{msg}")
- end
- end
-
def is_connected?
if @second_out.nil? or @second_out.closed? then
next
end
# write log first
- @log.output( l.strip, Log::LV_USER)
+ @log.output( line.strip, Log::LV_USER)
end
if not result then
return false, result_files
end
- result = client.read_lines do |l|
+ result = client.read_lines do |line|
if line.strip.start_with?("=JOB_STATUS") then
data = line.strip.split(",")
@job.remote_status = data[1]
end
# write log first
- @log.output( l.strip, Log::LV_USER)
+ line = line.sub(/^[a-zA-Z], \[.*\][ \t]*/,"")
+ @log.output( line.strip, Log::LV_USER)
# gather result files if not reverse build
- if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
+ if not is_rev_build and line =~ /Creating package file \.\.\. (.*)/ then
file_name = $1
result_files.push file_name
end
return new(socket, log)
end
+ def terminated?
+ return @socket.closed?
+ end
def get_error_msg()
return @error_msg
class NewLogger < Logger
def flush
- puts @logdev.dev.class
@logdev.dev.flush
end
end
Dir.chdir WORKING_DIR
end
-
end