scripts.mit.edu

MIT SIPB Script Services for Athena

Does scripts.mit.edu support Node.js?

Scripts supports Node.js as a runtime environment, but most existing Node.js apps are not compatible with a multi-server setup like scripts.mit.edu. Additionally, scripts.mit.edu does not support using the common http.createServer function. Read below to find out how to write or adapt Node.js code to run on scripts.mit.edu.

Scripts can be used to run your own Node.js code! To begin, you probably want to ensure to have your site run on Fedora 30.

Using typical Node conventions, you can usually replace your use of the http package with node-fastcgi and install the code as an executable file whose name ends with .fcgi.

See below for an example index.fcgi:

#!/usr/bin/node

var fcgi = require('node-fastcgi');

const express = require('express'),
      app = express(),
      http = fcgi.createServer(app);

app.get('/', function (req, res) {
   res.send("Hello World");
});

http.listen();

Naturally to do this, you need to install the node-fastcgi library. To do so, first you need to make sure you have a writable npm folder for your locker as follows:

% add consult
% mkdir -p /mit/lockername/.npm
% fsr sa /mit/lockername/.npm daemon.scripts write

From here, you can now ssh into scripts to install whatever packages you need (show for node-fastcgi):

% ssh -k lockername@scripts.mit.edu
% cd myapp
% npm i node-fastcgi

If you get an “Internal Server Error” despite having valid code, make sure that you have marked the script executable with chmod +x index.fcgi. You can diagnose your error by attempting to run your script directly at the prompt:

% ssh -k lockername@scripts.mit.edu
% cd myapp
% ./index.fcgi
Previous:
Next:
© 2004-2020, the SIPB scripts.mit.edu project.
These pages may be reused under either the GFDL 1.2 or CC-BY-SA 3.0.
Questions? Contact scripts@mit.edu.

You are currently connected to shining-armor.mit.edu.