Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2150 from ajaxorg/remove-process-types

[Liskov] Remove processTypes
  • Loading branch information...
commit af1afd5a5a39eee9085b1330f51cb5bc8c4d3d2a 2 parents 8b01212 + e726b3a
@nightwing nightwing authored
View
187 plugins-client/ext.console/console.js
@@ -120,7 +120,7 @@ module.exports = ext.register("ext/console/console", {
}
}
else {
- command_id = this.createNodeProcessLog(spi);
+ command_id = this.createProcessLog(spi);
}
this.tracerToPidMap[command_id] = spi;
@@ -403,8 +403,9 @@ module.exports = ext.register("ext/console/console", {
}
},
- createNodeProcessLog: function(message_pid) {
- var command_id = this.createOutputBlock("Running Node Process", true);
+ createProcessLog: function(message_pid, lang) {
+ lang = lang ? (lang[0].toUpperCase() + lang.substring(1)) : "Generic";
+ var command_id = this.createOutputBlock("Running " + lang + " Process", true);
this.tracerToPidMap[command_id] = message_pid;
this.pidToTracerMap[message_pid] = command_id;
@@ -416,58 +417,6 @@ module.exports = ext.register("ext/console/console", {
return command_id;
},
- createPhpProcessLog : function(message_pid) {
- var command_id = this.createOutputBlock("Running PHP Process", true);
- this.tracerToPidMap[command_id] = message_pid;
- this.pidToTracerMap[message_pid] = command_id;
-
- var containerEl = this.getLogStreamOutObject(command_id).$ext;
- containerEl.setAttribute("rel", command_id);
- apf.setStyleClass(containerEl, "has_pid");
-
- this.command_id_tracer++;
- return command_id;
- },
-
- createApacheProcessLog: function (message_pid) {
- var command_id = this.createOutputBlock("Running Apache Process", true);
- this.tracerToPidMap[command_id] = message_pid;
- this.pidToTracerMap[message_pid] = command_id;
-
- var containerEl = this.getLogStreamOutObject(command_id).$ext;
- containerEl.setAttribute("rel", command_id);
- apf.setStyleClass(containerEl, "has_pid");
-
- this.command_id_tracer++;
- return command_id;
- },
-
- createPythonProcessLog : function(message_pid) {
- var command_id = this.createOutputBlock("Running Python Process", true);
- this.tracerToPidMap[command_id] = message_pid;
- this.pidToTracerMap[message_pid] = command_id;
-
- var containerEl = this.getLogStreamOutObject(command_id).$ext;
- containerEl.setAttribute("rel", command_id);
- apf.setStyleClass(containerEl, "has_pid");
-
- this.command_id_tracer++;
- return command_id;
- },
-
- createRubyProcessLog : function(message_pid) {
- var command_id = this.createOutputBlock("Running Ruby Process", true);
- this.tracerToPidMap[command_id] = message_pid;
- this.pidToTracerMap[message_pid] = command_id;
-
- var containerEl = this.getLogStreamOutObject(command_id).$ext;
- containerEl.setAttribute("rel", command_id);
- apf.setStyleClass(containerEl, "has_pid");
-
- this.command_id_tracer++;
- return command_id;
- },
-
onMessage: function(e) {
if (!e.message.type)
return;
@@ -485,80 +434,62 @@ module.exports = ext.register("ext/console/console", {
this.command_id_tracer = extra.command_id + 1;
}
+ var lang;
+ if ((lang = /^(\w+)-start$/.exec(message.type))) {
+ var clearOnRun = settings.model.queryValue("auto/console/@clearonrun");
+ if (apf.isTrue(clearOnRun) && window["txtOutput"])
+ txtOutput.clear();
+
+ this.createProcessLog(message.pid, lang[1]);
+ return;
+ } else if ((lang = /^(\w+)-data$/.exec(message.type))) {
+ if (message.data && message.data.indexOf("Tip: you can") === 0) {
+ (function () {
+ var prjmatch = message.data.match(/http\:\/\/([\w_-]+)\.([\w_-]+)\./);
+ if (!prjmatch) return;
+
+ var user = prjmatch[2];
+ var project = prjmatch[1];
+
+ var urlPath = window.location.pathname.split("/").filter(function (f) { return !!f; });
+
+ if (project !== ide.projectName) {
+ // concurrency bug, project does not match
+ apf.ajax("/api/debug", {
+ method: "POST",
+ contentType: "application/json",
+ data: JSON.stringify({
+ agent: navigator.userAgent,
+ type: "Concurrency bug, project does not match",
+ e: [user, project, urlPath],
+ workspaceId: ide.workspaceId
+ })
+ });
+ }
+ else if (urlPath.length && user !== urlPath[0]) {
+ // concurrency bug, user does not match
+ apf.ajax("/api/debug", {
+ method: "POST",
+ contentType: "application/json",
+ data: JSON.stringify({
+ agent: navigator.userAgent,
+ type: "Concurrency bug, user does not match",
+ e: [user, project, urlPath],
+ workspaceId: ide.workspaceId
+ })
+ });
+ }
+ }());
+ }
+
+ logger.logNodeStream(message.data, message.stream, this.getLogStreamOutObject(message.pid, true), ide);
+ return;
+ } else if ((lang = /^(\w+)-exit$/.exec(message.type))) {
+ this.markProcessAsCompleted(message.pid, true);
+ return;
+ }
+
switch (message.type) {
- case "node-start":
- var clearOnRun = settings.model.queryValue("auto/console/@clearonrun");
- if (apf.isTrue(clearOnRun) && window["txtOutput"]) txtOutput.clear();
- this.createNodeProcessLog(message.pid);
- return;
- case "php-start":
- this.createPhpProcessLog(message.pid);
- return;
- case "apache-start":
- this.createApacheProcessLog(message.pid);
- return;
- case "python-start":
- this.createPythonProcessLog(message.pid);
- return;
- case "ruby-start":
- this.createRubyProcessLog(message.pid);
- return;
- case "node-data":
- case "apache-data":
- case "php-data":
- case "python-data":
- case "ruby-data":
- case "php-data":
- if (message.data && message.data.indexOf("Tip: you can") === 0) {
- (function () {
- var prjmatch = message.data.match(/http\:\/\/([\w_-]+)\.([\w_-]+)\./);
- if (!prjmatch) return;
-
- var user = prjmatch[2];
- var project = prjmatch[1];
-
- var urlPath = window.location.pathname.split("/").filter(function (f) { return !!f; });
-
- if (project !== ide.projectName) {
- // concurrency bug, project does not match
- apf.ajax("/api/debug", {
- method: "POST",
- contentType: "application/json",
- data: JSON.stringify({
- agent: navigator.userAgent,
- type: "Concurrency bug, project does not match",
- e: [user, project, urlPath],
- workspaceId: ide.workspaceId
- })
- });
- }
- else if (urlPath.length && user !== urlPath[0]) {
- // concurrency bug, user does not match
- apf.ajax("/api/debug", {
- method: "POST",
- contentType: "application/json",
- data: JSON.stringify({
- agent: navigator.userAgent,
- type: "Concurrency bug, user does not match",
- e: [user, project, urlPath],
- workspaceId: ide.workspaceId
- })
- });
- }
-
- return;
- }());
- }
-
- logger.logNodeStream(message.data, message.stream, this.getLogStreamOutObject(message.pid, true), ide);
- return;
- case "node-exit":
- case "php-exit":
- case "python-exit":
- case "ruby-exit":
- case "apache-exit":
- this.markProcessAsCompleted(message.pid, true);
- return;
case "npm-module-start":
if (!extra.original_line || !this.inited)
return;
View
30 plugins-client/ext.noderunner/noderunner.js
@@ -64,24 +64,20 @@ module.exports = ext.register("ext/noderunner/noderunner", {
//if (message.type != "shell-data")
// console.log("MSG", message)
- switch(message.type) {
- case "node-debug-ready":
- case "php-debug-ready":
- case "python-debug-ready":
- case "ruby-debug-ready":
- ide.dispatchEvent("dbg.ready", message);
- break;
- case "node-exit":
- case "php-exit":
- case "python-exit":
- case "ruby-exit":
- ide.dispatchEvent("dbg.exit", message);
- if (message.pid == this.nodePid) {
- stProcessRunning.deactivate();
- this.nodePid = 0;
- }
- break;
+ if (/^\w+-debug-ready$/.test(message.type)) {
+ ide.dispatchEvent("dbg.ready", message);
+ return;
+ }
+ else if (/^\w+-exit$/.test(message.type)) {
+ ide.dispatchEvent("dbg.exit", message);
+ if (message.pid == this.nodePid) {
+ stProcessRunning.deactivate();
+ this.nodePid = 0;
+ }
+ return;
+ }
+ switch(message.type) {
case "state":
this.nodePid = message.processRunning || 0;
stProcessRunning.setProperty("active", !!message.processRunning);
View
5 plugins-server/cloud9.ide.state/state.js
@@ -77,9 +77,8 @@ util.inherits(StatePlugin, Plugin);
// TODO could we just send all ps?
for (var pid in ps) {
var processType = ps[pid].type;
- if (processType == "node" || processType == "apache" || processType == "php" ||
- processType == "python" || processType == "ruby" || processType == "node-debug") {
- state[processType] = parseInt(pid);
+ if (self.pm.runnerTypes().indexOf(processType) >= 0) {
+ state[processType] = parseInt(pid, 10);
state.processRunning = pid;
if (processType.substr(-5) == "debug")
state.debugClient = pid;
View
3  plugins-server/cloud9.process-manager/process-manager-ext.js
@@ -17,6 +17,9 @@ module.exports = function setup(options, imports, register) {
ps: function(callback) {
callback(null, pm.ps());
},
+ runnerTypes: function () {
+ return Object.keys(runners);
+ },
debug: pm.debug.bind(pm),
spawn: pm.spawn.bind(pm),
exec: function(runnerId, options, callback) {
Please sign in to comment.
Something went wrong with that request. Please try again.