Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

java-code-runner

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-code-runner - npm Package Compare versions

Comparing version 0.4.2 to 0.4.3

watchServer.js

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

4

node/config.js
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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc