Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
overcome rscript bug, now checks if port is free or not
Browse files Browse the repository at this point in the history
  • Loading branch information
markuskonk committed May 24, 2018
1 parent bcc6809 commit 61a88f1
Show file tree
Hide file tree
Showing 17 changed files with 1,433 additions and 1,036 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM rocker/geospatial:latest

SHELL ["/bin/bash", "-c"]

RUN R -e 'install.packages(c("diveMove", "trip", "adehabitatLT", "plm", "cshapes", "plumber"))'
RUN R -e 'install.packages(c("diveMove", "trip", "adehabitatLT", "plm", "cshapes", "plumber", "STEPCAM", "MCMCglmm", "gdistance", "compositions"))'
# based on https://gist.github.com/remarkablemark/aacf14c29b3f01d6900d13137b21db3a
RUN apt-get update \
&& apt-get install -y curl \
Expand Down
24 changes: 18 additions & 6 deletions controllers/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const bodyParser = require('body-parser');
const debug = require('debug')('bindings');
const rscript = require('r-script');
const path = require('path');

const net = require('net');
const fn = require('./generalFunctions');

let bindings = {};
Expand Down Expand Up @@ -94,11 +94,23 @@ bindings.showFigureDataCode = function(binding) {
};

bindings.runR = function(binding) {
debug('Start running R script for %s', binding.result.value);
let run = rscript(path.join(path.join('tmp', 'o2r', 'compendium',
binding.id, binding.result.value.replace(/\s/g, '').toLowerCase() + 'run.R')))
.call(function(err, d) {
debug('Started service: %s', binding.result.value);
let server = net.createServer(function(socket) {
socket.write('Echo server\r\n');
socket.pipe(socket);
});

server.listen(binding.port, 'localhost');
server.on('error', function (e) {
debug("port %s is not free", binding.port);
});
server.on('listening', function (e) {
server.close();
debug("port %s is free", binding.port);
let filepath = path.join('tmp', 'o2r', 'compendium', binding.id, binding.result.value.replace(/\s/g, '').toLowerCase() + 'run.R');
let run = rscript(filepath)
.call(function(err, d) {
debug('Started service: %s', binding.result.value);
});
});
};

Expand Down
Binary file modified controllers/spacetime/.RData
Binary file not shown.
Loading

0 comments on commit 61a88f1

Please sign in to comment.