Spanish Total.js
English
Documentation For AI agents
Contents

Run a plain Node.js app

Host a Node.js app that is not a Total.js app with the Custom type.

.md GitHub
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

  1. Select Add > App and type the URL address, for example http://node.example.com.
  2. Clear Enable debug mode.
  3. Under Type of application, choose Custom.
  4. In Custom start script, type server.js.
  5. Select SUBMIT.
  6. 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 --release

The 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.

Made in Europe