[title] fixed some bug
authordibs <dibs@samsung.com>
Wed, 27 Mar 2013 12:16:58 +0000 (21:16 +0900)
committerdibs <dibs@samsung.com>
Wed, 27 Mar 2013 12:16:58 +0000 (21:16 +0900)
build-cli
dibs-web/app/controllers/jobs_controller.rb
dibs-web/app/controllers/utils.rb
dibs-web/public/javascripts/projects.js
src/build_server/BuildServer.rb
src/build_server/JobLog.rb
src/build_server/RemoteBuilder.rb
src/common/BuildComm.rb
src/common/log.rb
src/common/utils.rb

index 686de05fbdaf17163d74f4e4e5e16a9a47d2b700..14bc404ae32ab39b409e8221e2f884501e5af1d5 100755 (executable)
--- 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
index 8cd911c61ebe1eccac740e2382ee22100e89bf78..197440b248b652c2118746bc6c3356490102d6b9 100644 (file)
@@ -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
index 0ed307a1dcc4c41febe4afb1260e50331ea51789..7c928bf72e8cd96d4bb24dfbcaa7071a57a4e3fd 100644 (file)
@@ -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)
index e982f67efd6af783b464336ac4f07fba4f878c3e..fdfb8cb18f570080a70dd8d43f09f35e36596fce 100644 (file)
@@ -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 = '<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>";
index 4486a0b25b4973763c65fd8ef5e146e07d2f6d3b..202d97fa8b4d3ef64f722b598a90c6a666d6152e 100644 (file)
@@ -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}"
index c5c9b4daa95fa0af4b809dc0676573f57461bf1f..2dade4432a0e80e450a75da6689845b6db29bc74 100644 (file)
@@ -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
index 1a00262de129549fdb9336da3425c14d00bd3a4d..56b4638fc15fd7064a6e9aa4aaafda73331322b6 100644 (file)
@@ -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
index 55e9108ce64f68d533b8e400f24bcc5dc80dc73c..7e95dee35ba94741b313cf867d622da462535028 100644 (file)
@@ -373,6 +373,9 @@ class BuildCommClient
                return new(socket, log)
        end
 
+       def terminated?
+               return @socket.closed?
+       end
 
        def get_error_msg()
                return @error_msg
index dec73af70fc5ae8e7146f3de6820e9ee861bf21b..facd41c23b3ff13d0420e4fe9c6191553a6845cf 100644 (file)
@@ -30,7 +30,6 @@ require "logger"
 
 class NewLogger < Logger
        def flush
-               puts @logdev.dev.class
                @logdev.dev.flush
        end
 end
index 8e0aa2c659176a7b3d0e74e63b7c6c4467578505..90cb5b8df13731d5eb990132f462d245ed8324a9 100644 (file)
@@ -685,5 +685,4 @@ class Utils
                Dir.chdir WORKING_DIR
        end
 
-
 end