From: dibs Date: Wed, 27 Mar 2013 12:16:58 +0000 (+0900) Subject: [title] fixed some bug X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22ef1ae30b348f301727391668ac82756db92cdc;p=sdk%2Ftools%2Fsdk-build.git [title] fixed some bug --- diff --git a/build-cli b/build-cli index 686de05..14bc404 100755 --- a/build-cli +++ b/build-cli @@ -217,7 +217,10 @@ begin 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 @@ -252,7 +255,10 @@ begin client.terminate rescue => e puts "ERROR: #{e}" - client.terminate + result = false + if not client.terminated? then + client.terminate + end end end @@ -358,7 +364,11 @@ begin next end # print log - puts line + log.puts line + end + + if not output.nil? then + log.puts "=LOG_END" end if not result then diff --git a/dibs-web/app/controllers/jobs_controller.rb b/dibs-web/app/controllers/jobs_controller.rb index 8cd911c..197440b 100644 --- a/dibs-web/app/controllers/jobs_controller.rb +++ b/dibs-web/app/controllers/jobs_controller.rb @@ -536,15 +536,28 @@ class JobsController < ApplicationController # 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 @@ -567,21 +580,9 @@ class JobsController < ApplicationController 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 diff --git a/dibs-web/app/controllers/utils.rb b/dibs-web/app/controllers/utils.rb index 0ed307a..7c928bf 100644 --- a/dibs-web/app/controllers/utils.rb +++ b/dibs-web/app/controllers/utils.rb @@ -113,7 +113,7 @@ puts "[[[#{cmd}]]]" 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? @@ -122,13 +122,6 @@ puts "[[[#{cmd}]]]" 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 @@ -138,6 +131,8 @@ puts "[[[#{cmd}]]]" options = options + " --output #{path}" cmd = "#{DIBS_PATH}/build-cli query-log #{options}" +puts "Query-log command" +puts "[[[#{cmd}]]]" fork do exec(cmd) diff --git a/dibs-web/public/javascripts/projects.js b/dibs-web/public/javascripts/projects.js index e982f67..fdfb8cb 100644 --- a/dibs-web/public/javascripts/projects.js +++ b/dibs-web/public/javascripts/projects.js @@ -88,7 +88,6 @@ function projectsQueryProjectListType(queryType) { $('.projects-project-list-collapsible').collapsible(); $('.projects-project-list-listview').listview(); - }); } @@ -115,6 +114,12 @@ function projectsAppendProjectList( project, projectList ) { h2.innerHTML = ''+name+''+type+''; div.appendChild(h2); + var testDiv = document.createElement('div'); + //testDiv.innerHTML = ''; + testDiv.innerHTML = '
Font styling:
'; + h2.appendChild(testDiv); + $('#checkbox-6').checkboxradio(); + var infoLine = document.createElement('p'); infoLine.setAttribute('style', 'font-size: 12px'); infoLine.innerHTML = "Maintainer : "+maintainer+"

"; diff --git a/src/build_server/BuildServer.rb b/src/build_server/BuildServer.rb index 4486a0b..202d97f 100644 --- a/src/build_server/BuildServer.rb +++ b/src/build_server/BuildServer.rb @@ -223,7 +223,7 @@ class BuildServer 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 @@ -788,7 +788,7 @@ class BuildServer 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 @@ -803,8 +803,7 @@ class BuildServer # 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 @@ -825,6 +824,10 @@ class BuildServer 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}" diff --git a/src/build_server/JobLog.rb b/src/build_server/JobLog.rb index c5c9b4d..2dade44 100644 --- a/src/build_server/JobLog.rb +++ b/src/build_server/JobLog.rb @@ -69,14 +69,6 @@ class JobLog < Log @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 diff --git a/src/build_server/RemoteBuilder.rb b/src/build_server/RemoteBuilder.rb index 1a00262..56b4638 100644 --- a/src/build_server/RemoteBuilder.rb +++ b/src/build_server/RemoteBuilder.rb @@ -198,7 +198,7 @@ class RemoteBuilder next end # write log first - @log.output( l.strip, Log::LV_USER) + @log.output( line.strip, Log::LV_USER) end if not result then @@ -233,7 +233,7 @@ class RemoteBuilder 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] @@ -242,10 +242,11 @@ class RemoteBuilder 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 diff --git a/src/common/BuildComm.rb b/src/common/BuildComm.rb index 55e9108..7e95dee 100644 --- a/src/common/BuildComm.rb +++ b/src/common/BuildComm.rb @@ -373,6 +373,9 @@ class BuildCommClient return new(socket, log) end + def terminated? + return @socket.closed? + end def get_error_msg() return @error_msg diff --git a/src/common/log.rb b/src/common/log.rb index dec73af..facd41c 100644 --- a/src/common/log.rb +++ b/src/common/log.rb @@ -30,7 +30,6 @@ require "logger" class NewLogger < Logger def flush - puts @logdev.dev.class @logdev.dev.flush end end diff --git a/src/common/utils.rb b/src/common/utils.rb index 8e0aa2c..90cb5b8 100644 --- a/src/common/utils.rb +++ b/src/common/utils.rb @@ -685,5 +685,4 @@ class Utils Dir.chdir WORKING_DIR end - end