Skip to content

Run a Node.js application

Want to run a Node.js application on Cyberfusion?

There are two paths depending on whether the application needs to be reachable over the web or just runs in the background. This article covers both.


Which path you need

  • The app answers HTTP requests, such as an SSR framework (Next.js, Nuxt, Astro) or a custom API → Web-accessible, three steps.
  • The app runs in the background, such as a queue worker or a poller → Background only, one step.

Do the prerequisites below first, whichever path you take.

Prerequisites

  1. Add the 'Node.js' node group to the servers that will run the app. Also add 'Passenger' if the app is web-accessible. Steps: Add a node group.
  2. Make sure you have a UNIX user with a 'Default NodeJS Version' set. The app runs as that user and uses that version.

No suitable UNIX user yet? Create one at 'Advanced' > 'UNIX Users' > 'Create UNIX User' and set 'Default NodeJS Version' in the form. Full flow: All about UNIX users.

Web-accessible (via Passenger)

  1. Create a Passenger app on the UNIX user. See All about Passenger apps for the create flow, the app-root constraint, and the sizing fields.
  2. Attach it to a virtual host: pick 'NodeJS' as the language and select your Passenger app from the dropdown. See All about virtual hosts.
  3. Point DNS for the domain at Cyberfusion. A Let's Encrypt certificate is issued automatically. See Let's Encrypt certificates.

The app is then reachable at that domain over HTTPS.

Cyberfusion runs the app via Phusion Passenger: it supervises the worker pool, restarts workers that hit their memory limit, and routes traffic to the right backend.

Background only (as a daemon)

Navigate to 'Advanced' > 'UNIX Users' > the UNIX user > 'Daemons' > '+'. Fill in:

  • The command to run, for example node /home/user/worker.js.
  • Which servers the daemon should run on.

The daemon runs continuously. If it dies or hits its memory limit, Cyberfusion restarts it.

Field reference and the restart trigger file you can call from a deploy script: Daemons.