forked from cory/tildefriends
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:
parent
db6467187d
commit
84c8d74d2a
32
core/core.js
32
core/core.js
@ -150,6 +150,12 @@ function postMessageInternal(from, to, message) {
|
|||||||
return invoke(to.eventHandlers['onMessage'], [getUser(from, from), 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) {
|
async function getService(service, packageName) {
|
||||||
let process = this;
|
let process = this;
|
||||||
let serviceName = process.packageName + '_' + service;
|
let serviceName = process.packageName + '_' + service;
|
||||||
@ -157,6 +163,7 @@ async function getService(service, packageName) {
|
|||||||
return serviceProcess.ready.then(function() {
|
return serviceProcess.ready.then(function() {
|
||||||
return {
|
return {
|
||||||
postMessage: postMessageInternal.bind(process, process, serviceProcess),
|
postMessage: postMessageInternal.bind(process, process, serviceProcess),
|
||||||
|
kill: killProcess.bind(process, serviceProcess),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -228,11 +235,6 @@ async function getManifest(fileName) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function packageNameToPath(name) {
|
|
||||||
var process = this;
|
|
||||||
return "packages/" + process.packageOwner + "/" + name + "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getProcess(packageOwner, packageName, key, options) {
|
async function getProcess(packageOwner, packageName, key, options) {
|
||||||
var process = gProcesses[key];
|
var process = gProcesses[key];
|
||||||
if (!process
|
if (!process
|
||||||
@ -365,17 +367,13 @@ async function getProcess(packageOwner, packageName, key, options) {
|
|||||||
print("Activating task");
|
print("Activating task");
|
||||||
process.task.activate();
|
process.task.activate();
|
||||||
print("Executing task");
|
print("Executing task");
|
||||||
process.task.execute({name: fileName, source: readFileUtf8(fileName)}).then(function() {
|
await process.task.execute({name: fileName, source: readFileUtf8(fileName)});
|
||||||
print("Task ready");
|
print("Task ready");
|
||||||
broadcastEvent('onSessionBegin', [getUser(process, process)]);
|
broadcastEvent('onSessionBegin', [getUser(process, process)]);
|
||||||
resolveReady(process);
|
resolveReady(process);
|
||||||
if (process.terminal) {
|
if (process.terminal) {
|
||||||
process.terminal.print({action: "ready"});
|
process.terminal.print({action: "ready"});
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
|
||||||
printError(process.terminal, error);
|
|
||||||
rejectReady();
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
printError(process.terminal, error);
|
printError(process.terminal, error);
|
||||||
rejectReady();
|
rejectReady();
|
||||||
@ -431,8 +429,6 @@ try {
|
|||||||
print("Error loading settings from " + kGlobalSettingsFile + ": " + error);
|
print("Error loading settings from " + kGlobalSettingsFile + ": " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
var kIgnore = ["/favicon.ico"];
|
|
||||||
|
|
||||||
var auth = require("auth");
|
var auth = require("auth");
|
||||||
var httpd = require("httpd");
|
var httpd = require("httpd");
|
||||||
httpd.all("/login", auth.handler);
|
httpd.all("/login", auth.handler);
|
||||||
|
@ -43,9 +43,6 @@ Terminal.prototype.dispatch = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Terminal.prototype.feedWaiting = function(waiting, data) {
|
|
||||||
}
|
|
||||||
|
|
||||||
Terminal.prototype.print = function() {
|
Terminal.prototype.print = function() {
|
||||||
var data = arguments;
|
var data = arguments;
|
||||||
if (this._selected) {
|
if (this._selected) {
|
||||||
|
Loading…
Reference in New Issue
Block a user