Run a plain Node.js app
Host a Node.js app that is not a Total.js app with the Custom type.
On this page
SuperAdmin can run any Node.js app that listens on a port. Choose the type Custom and give the name of your start script.
SuperAdmin starts the script with Node.js and two arguments: the port number and the mode, --release or --debug. Your app must listen on that port on 127.0.0.1.
Example app
A file server.js:
var http = require('http');
var port = +process.argv[2];
var mode = process.argv[3];
http.createServer(function(req, res) {
res.end('Hello from a plain Node.js app (' + mode + ')');
}).listen(port, '127.0.0.1');
console.log('Listening on ' + port + ' ' + mode);Pack it into a ZIP file with server.js at the top level.
Add the app
- Select Add > App and type the URL address, for example
http://node.example.com. - Clear Enable debug mode.
- Under Type of application, choose Custom.
- In Custom start script, type
server.js. - Select SUBMIT.
- In Upload source-code, upload the ZIP file. See Upload source code.
SuperAdmin runs a command like this one:
node --nouse-idle-notification --expose-gc /www/www/example_com-node/server.js 8001 --releaseThe port is shown next to the name of the app in the list. Open the address of the app: it answers Hello from a plain Node.js app (--release).
The output of console.log goes to the log of the app. See Logs and analyzator.
With Memory limit, SuperAdmin adds --max_old_space_size with your value to the command.