Commit db6394b8 authored by Efthymia Bika's avatar Efthymia Bika

Kill running processes on exit

parent ba9ed922
...@@ -25,10 +25,13 @@ var BAAS_HOME_DIR = '.baas'; ...@@ -25,10 +25,13 @@ var BAAS_HOME_DIR = '.baas';
var CLOUDS_CONF_FILE = 'clouds.rc'; var CLOUDS_CONF_FILE = 'clouds.rc';
var BACKUP_CONF_FILE = 'backups.rc'; var BACKUP_CONF_FILE = 'backups.rc';
var TEMPLATES_FILE = 'templates.rc'; var TEMPLATES_FILE = 'templates.rc';
var BAAS_LOG_DIR = path.join(get_user_home(), BAAS_HOME_DIR, 'log'); var BAAS_LOG_DIR = path.join(get_user_home(), BAAS_HOME_DIR, 'log');
var BAAS_CACHE_DIR = path.join(get_user_home(), BAAS_HOME_DIR, 'cache'); var BAAS_CACHE_DIR = path.join(get_user_home(), BAAS_HOME_DIR, 'cache');
var RESTORE_DEFAULT_DIR = path.join(get_user_home(), "Downloads"); var RESTORE_DEFAULT_DIR = path.join(get_user_home(), "Downloads");
var running_processes = [];
var exec_path = path.dirname(process.execPath); var exec_path = path.dirname(process.execPath);
if(process.platform == 'darwin') { if(process.platform == 'darwin') {
exec_path = path.join( exec_path = path.join(
...@@ -188,3 +191,17 @@ function getClient(name, URL, token, CAPath) { ...@@ -188,3 +191,17 @@ function getClient(name, URL, token, CAPath) {
if (clients[name].getCA() !== CAPath) clients[name].setCA(CAPath); if (clients[name].getCA() !== CAPath) clients[name].setCA(CAPath);
return clients[name]; return clients[name];
} }
function kill_callback(error, stdout, stderr) {
if(error) {
console.error(stderr);
}
console.log(stdout);
}
function kill_processes() {
for(var i = 0; i < running_processes.length; i++) {
console.log(running_processes[i]);
running_processes[i].kill();
}
}
...@@ -178,6 +178,7 @@ function call_duplicity(mode, backup_set, force) { ...@@ -178,6 +178,7 @@ function call_duplicity(mode, backup_set, force) {
build_extra_args(backup_set.include, "include", args); build_extra_args(backup_set.include, "include", args);
build_extra_args(backup_set.exclude, "exclude", args); build_extra_args(backup_set.exclude, "exclude", args);
args.push("-v8"); args.push("-v8");
$('html,body').animate({ $('html,body').animate({
scrollTop: $("#msg_div").offset().top}, 1000); scrollTop: $("#msg_div").offset().top}, 1000);
break; break;
...@@ -245,6 +246,7 @@ function call_duplicity(mode, backup_set, force) { ...@@ -245,6 +246,7 @@ function call_duplicity(mode, backup_set, force) {
} else { } else {
wProcess = spawn(DUPLICITY_PATH, args); wProcess = spawn(DUPLICITY_PATH, args);
} }
running_processes.push(wProcess);
var output_str = ""; var output_str = "";
function dup_call_out(data) { function dup_call_out(data) {
...@@ -285,6 +287,7 @@ function call_duplicity(mode, backup_set, force) { ...@@ -285,6 +287,7 @@ function call_duplicity(mode, backup_set, force) {
function dup_call_exit(code) { function dup_call_exit(code) {
console.log("exit code === " + code); console.log("exit code === " + code);
running_processes.pop(wProcess);
$("#loader").hide(); $("#loader").hide();
if(mode == "backup") { if(mode == "backup") {
disable_actions(false); disable_actions(false);
......
...@@ -46,6 +46,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -46,6 +46,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
win.resizeTo(900, 750); win.resizeTo(900, 750);
win.focus(); win.focus();
win.on('close', function() {
this.hide(); // Pretend to be closed already
kill_processes();
this.close(true);
});
$(document).ready(function() { $(document).ready(function() {
$("#activity-link").trigger("click").addClass("active"); $("#activity-link").trigger("click").addClass("active");
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment