Minor cleanup, and allow killing service processes.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3407 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2017-05-23 17:47:48 +00:00
parent db6467187d
commit 84c8d74d2a
2 changed files with 14 additions and 21 deletions

View File

@ -150,6 +150,12 @@ function postMessageInternal(from, to, message) {
return invoke(to.eventHandlers['onMessage'], [getUser(from, from), message]);
}
function killProcess(process) {
if (process && process.task) {
return process.task.kill();
}
}
async function getService(service, packageName) {
let process = this;
let serviceName = process.packageName + '_' + service;
@ -157,6 +163,7 @@ async function getService(service, packageName) {
return serviceProcess.ready.then(function() {
return {
postMessage: postMessageInternal.bind(process, process, serviceProcess),
kill: killProcess.bind(process, serviceProcess),
}
});
}
@ -228,11 +235,6 @@ async function getManifest(fileName) {
return result;
}
function packageNameToPath(name) {
var process = this;
return "packages/" + process.packageOwner + "/" + name + "/";
}
async function getProcess(packageOwner, packageName, key, options) {
var process = gProcesses[key];
if (!process
@ -365,17 +367,13 @@ async function getProcess(packageOwner, packageName, key, options) {
print("Activating task");
process.task.activate();
print("Executing task");
process.task.execute({name: fileName, source: readFileUtf8(fileName)}).then(function() {
print("Task ready");
broadcastEvent('onSessionBegin', [getUser(process, process)]);
resolveReady(process);
if (process.terminal) {
process.terminal.print({action: "ready"});
}
}).catch(function(error) {
printError(process.terminal, error);
rejectReady();
});
await process.task.execute({name: fileName, source: readFileUtf8(fileName)});
print("Task ready");
broadcastEvent('onSessionBegin', [getUser(process, process)]);
resolveReady(process);
if (process.terminal) {
process.terminal.print({action: "ready"});
}
} catch (error) {
printError(process.terminal, error);
rejectReady();
@ -431,8 +429,6 @@ try {
print("Error loading settings from " + kGlobalSettingsFile + ": " + error);
}
var kIgnore = ["/favicon.ico"];
var auth = require("auth");
var httpd = require("httpd");
httpd.all("/login", auth.handler);

View File

@ -43,9 +43,6 @@ Terminal.prototype.dispatch = function(data) {
}
}
Terminal.prototype.feedWaiting = function(waiting, data) {
}
Terminal.prototype.print = function() {
var data = arguments;
if (this._selected) {