From: Heekyoung, Oh Date: Tue, 18 Apr 2017 08:06:13 +0000 (+0900) Subject: [TIC-Web] Save the pid each jobs X-Git-Tag: v20170428~12^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a355245db684c27faaed3b084d80bbb573feac64;p=archive%2F20170607%2Ftools%2Ftic.git [TIC-Web] Save the pid each jobs - Add the column that pid, on tic_job table - The pid updated, when mic running started. - The pid saved, for that using 'cancel' function. - Remove blink button effect. Change-Id: Ib1f1e4456164e510066f3f6fdd6119bae70b7391 Signed-off-by: Heekyoung, Oh --- diff --git a/config.json b/config.json index 8485d2c..639c576 100644 --- a/config.json +++ b/config.json @@ -39,7 +39,8 @@ "MIC_AVAILABLE_FROM": "ws/mic/available/from", "MIC_AVAILABLE_TO": "ws/mic/available/to", "MIC_NEXT_JOB_FROM": "ws/mic/nextjob/from", - "MIC_NEXT_JOB_TO": "ws/mic/nextjob/to" + "MIC_NEXT_JOB_TO": "ws/mic/nextjob/to", + "MIC_ADD_PID_JOB_TO": "ws/mic/pid/to" }, "JOB": { "JOB_GET_ALL_COUNT": "/api/job/count/all", diff --git a/controller/dbquery.js b/controller/dbquery.js index 4898d0d..58b214a 100644 --- a/controller/dbquery.js +++ b/controller/dbquery.js @@ -48,6 +48,7 @@ mariadb.queries = { 'select tic_job.job_id job_id, ', 'tic_job.job_status job_status, ', 'tic_job.job_image_id job_image_id, ', + 'tic_job.job_pid job_pid, ', 'tic_image.image_name job_image_name, ', 'tic_image.image_size job_image_size, ', 'tic_job.job_hasksfile job_hasksfile, ', @@ -74,6 +75,7 @@ mariadb.queries = { 'select tic_job.job_id job_id, ', 'tic_job.job_status job_status, ', 'tic_job.job_image_id job_image_id, ', + 'tic_job.job_pid job_pid, ', 'tic_image.image_name job_image_name, ', 'tic_image.image_size job_image_size, ', 'tic_job.job_hasksfile job_hasksfile, ', @@ -90,6 +92,7 @@ mariadb.queries = { 'select tic_job.job_id job_id, ', 'tic_job.job_status job_status, ', 'tic_job.job_image_id job_image_id, ', + 'tic_job.job_pid job_pid, ', 'tic_image.image_name job_image_name, ', 'tic_image.image_size job_image_size, ', 'tic_job.job_hasksfile job_hasksfile, ', @@ -160,7 +163,7 @@ mariadb.doQuery = function doQuery(queryString) { */ mariadb.editJob = function editJob(req, res) { var queryString, strJobId, reqParam, - job_status, job_deleted, job_hasksfile, job_image_id, job_ks, job_arch, job_updater; + job_status, job_deleted, job_hasksfile, job_image_id, job_ks, job_arch, job_updater, job_pid; function onSuccess(rows) { logger.info('editJob.success'); @@ -176,11 +179,15 @@ mariadb.editJob = function editJob(req, res) { job_ks = reqParam.job_ks; job_arch = reqParam.job_arch; job_updater = reqParam.job_updater; + job_pid = reqParam.job_pid; queryString = 'update tic_job set'; if (job_image_id) { queryString += ' job_image_id = "' + job_image_id + '",'; } + if (job_pid) { + queryString += ' job_pid = "' + job_pid + '",'; + } if (job_status) { queryString += ' job_status = "' + job_status + '",'; } diff --git a/controller/mic.js b/controller/mic.js index 0b0a988..9da93ef 100644 --- a/controller/mic.js +++ b/controller/mic.js @@ -95,10 +95,8 @@ Mic.kill = function kill(paramObj) { } Mic.process = function process(command, callback, jobId) { - var ps; - // execution - ps = exec(command); + var ps = exec(command); // Process Manager - add processMgr.push({ @@ -114,6 +112,8 @@ Mic.process = function process(command, callback, jobId) { }); ps.on('error', callback.error); ps.on('exit', callback.exit); + + return ps; }; /** @@ -149,7 +149,7 @@ Mic.create = function create(paramObj, io) { io.sockets.emit(path, msgObj); } - Mic.process( + var ps = Mic.process( micCommand, { stdout: function (out) { @@ -196,6 +196,13 @@ Mic.create = function create(paramObj, io) { }, strJobId ); + + if (ps && ps.pid) { + sendMsg(AppConfig.EVENT.SOCKET.MIC_ADD_PID_JOB_TO, { + jobId: strJobId, + jobProcessId: ps.pid, + }); + } }; Mic.init = function init () { diff --git a/public/src/js/page/job.js b/public/src/js/page/job.js index ef7a6ea..9948838 100644 --- a/public/src/js/page/job.js +++ b/public/src/js/page/job.js @@ -222,18 +222,16 @@ define([ }); } - function _btnLogBlink(jobId, bBlink) { - var btnLogSelector, btnLogElem; - btnLogSelector = '#tic-job-list #job_table_row_' + jobId + ' .btnbiglog'; - btnLogElem = $(btnLogSelector); - if (!btnLogElem.hasClass('btnlogactive')) { - if (bBlink) { - btnLogElem.addClass('btnlogactive'); - } else { - btnLogElem.removeClass('btnlogactive'); - } - } - } + client.on(AppConfig.EVENT.SOCKET.MIC_ADD_PID_JOB_TO, function (dataObj) { + var msgObj = { + job_id: dataObj.jobId, + job_status: JOB_STATUS_INPROGRESS, + job_pid: dataObj.jobProcessId, + job_updater: UserInfo.email + }; + logger.error('MIC_ADD_PID_JOB_TO: ' + JSON.stringify(msgObj)); + return Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + dataObj.jobId, msgObj); + }); /** * when has the next job @@ -252,7 +250,6 @@ define([ * AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_TO = 'ws/fs/image/add/to' */ client.on(AppConfig.EVENT.SOCKET.FS_IMAGE_ADD_TO, function (dataObj) { - _btnLogBlink(dataObj.jobId, true); return new JobLog(dataObj); }); @@ -282,8 +279,6 @@ define([ jobId: jobId }); - _btnLogBlink(dataObj.jobId, false); - function onError(err) { if (err) { logger.error(err); @@ -316,7 +311,7 @@ define([ }; logger.info('IMAGE_ADD_FINISH.updateJobInfo: ' + JSON.stringify(msgObj)); - return Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + jobId, msgObj) + return Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + jobId, msgObj); } /** @@ -392,7 +387,6 @@ define([ // notification popup Util.showAlertDialog('Failed to create an image. The #ID is ' + jobId + '.'); - _btnLogBlink(dataObj.jobId, false); // update the status msgObj = {