java-code-runner
Advanced tools
Comparing version 0.4.2 to 0.4.3
12
index.js
@@ -18,2 +18,14 @@ var cp = require('child_process'); | ||
exports.watchServer = function () { | ||
server.startServer(); | ||
setInterval(function () { | ||
// console.log("watching "+ server.didExit()); | ||
if(server.didExit()) { | ||
server.restartServer(); | ||
} | ||
},1000); | ||
}; | ||
/** | ||
@@ -20,0 +32,0 @@ * Spawn a java process and return callback |
module.exports = { | ||
rootDir: __dirname+'/../', // root dir for ant to build | ||
timeLimit: 5000, // default running limit for code submission | ||
timeLimit: 2000, // default running limit for code submission | ||
defaultPort: 3678, // default port picked it at random | ||
runningLimit: 500 // maximum number of submissions to run in parallel | ||
runningLimit: 1000 // maximum number of submissions to run in parallel | ||
}; |
@@ -108,6 +108,8 @@ var log = require('util').log; | ||
}); | ||
observer.on("server.exit", function () { | ||
if (waitingQueue.length>0) { | ||
observer.emit("server.checkup"); | ||
observer.on("server.exit", function (code) { | ||
log("recived server exit in Queue " +code); | ||
if (waitingQueue.length>0 || code===null) { | ||
log("should restart"); | ||
observer.emit("server.restart"); | ||
} | ||
}); |
@@ -19,10 +19,15 @@ // a set of functions that are useful for the project | ||
var startingServer = false; // flag if server is ready to reseave post requests | ||
var serverExit = false; // flag if server is ready to reseave post requests | ||
var servletPort; | ||
var servlet = null; | ||
var isReady = exports.isReady = function isReady () { | ||
var didExit = exports.didExit = function () { | ||
return serverExit; | ||
}; | ||
var isReady = exports.isReady = function () { | ||
return servletReady; | ||
}; | ||
var isStarting = exports.isStarting = function isStarting () { | ||
var isStarting = exports.isStarting = function () { | ||
return startingServer; | ||
@@ -86,2 +91,7 @@ }; | ||
function resetFlags () { | ||
servlet = global._servlet = servletPort = global._servletPort = null; | ||
servletReady = startingServer = false; | ||
tryPort = defaultPort; | ||
} | ||
/** | ||
@@ -101,5 +111,3 @@ * Exposed method for stoping server | ||
if (servlet) servlet.kill(); | ||
servlet = global._servlet = servletPort = global._servletPort = null; | ||
servletReady = startingServer = false; | ||
tryPort = defaultPort; | ||
resetFlags(); | ||
log("Stoped Server"); | ||
@@ -115,4 +123,6 @@ observer.emit('server.stoped', kill); | ||
log("Restarting server"); | ||
stopServer(function () { | ||
startServlet(cb); | ||
serverExit = false; | ||
stopServer(function (isRunning) { | ||
log(isRunning +" couldn't stop "); | ||
startServlet(cb); | ||
}); | ||
@@ -148,7 +158,15 @@ }; | ||
servlet.on('exit', function(code) { | ||
servletReady = false; | ||
log('servlet exist with code ' + code); | ||
observer.emit('server.exit'); | ||
servlet.on('close',function (code, signal) { | ||
resetFlags(); | ||
log("exited from close with arguments "+code+" "+signal); | ||
observer.emit('server.close'. code); | ||
}); | ||
servlet.on('exit', function(code, signal) { | ||
resetFlags(); | ||
if(code===null || signal===null) { | ||
serverExit = true; | ||
} | ||
log('servlet exist with code ' + code + 'signal '+signal); | ||
observer.emit('server.exit'. code); | ||
}); | ||
// make sure to close server after node process ends | ||
@@ -155,0 +173,0 @@ process.on('exit', function() { |
{ | ||
"name": "java-code-runner", | ||
"version": "0.4.02", | ||
"version": "0.4.03", | ||
"author": "Amr Draz", | ||
@@ -5,0 +5,0 @@ "repository": { |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1745279
37
1363