Skip to content

Commit 624cd21

Browse files
committed
Make sure the Code Pulse backend doesn't run twice
1 parent 27bcca3 commit 624cd21

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

distrib/common/app/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ function getJava() {
5656
}
5757
}
5858

59+
var started = false;
60+
5961
function startCodePulse() {
62+
if (started) return;
63+
started = true;
64+
6065
var spawn = require('child_process').spawn,
6166
chmodSync = require('fs').chmodSync;
6267

@@ -177,15 +182,14 @@ function checkNewCPEvent(event, listener) {
177182
}
178183

179184
exports.codepulse = {
185+
start: startCodePulse,
180186
kill: killCodePulse,
181187
addListener: cpEvent.addListener,
182188
on: function(event, listener) { checkNewCPEvent(event, listener); cpEvent.on(event, listener); return exports.codepulse; },
183189
once: function(event, listener) { if (checkNewCPEvent(event, listener)) cpEvent.once(event, listener); return exports.codepulse; },
184190
removeListener: function(event, listener) { cpEvent.removeListener(event, listener); return exports.codepulse; }
185191
};
186192

187-
startCodePulse();
188-
189193
function checkWindowClose(window, cb) {
190194
if (cpUrl) {
191195
// make sure we don't wait any longer than 10 seconds

distrib/common/app/startup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ function redirect(cpUrl) {
5454
}
5555

5656
window.onload = function() {
57+
// fire up the backend
58+
codepulse.start();
59+
5760
// get the log all wired up
5861
updateLog(log.getContents());
5962
log.on('log', updateLog);

0 commit comments

Comments
 (0)