Skip to main content

Node.js Single-Process

On KloudBean, you get a complete production-ready stack to build and host high-performance Node.js applications with ease in just a few steps.

You get:

  • Git Integration: Pull your code on the server
  • SSH Access: Access to the server to run commands manually and using ADM tool for quick deployment
  • File Manager Access: Add, update, and manage files with ease

Launch New Node.js Application

note

If you already have a server and wish to launch an app on it, go to ApplicationsAdd Application and add a Node.js app on the existing server.

In this example, we will create a brand new server.

In order to launch your first Node.js app on a new server, navigate to the server provision page:

  1. Select Cloud Provider (your choice)
  2. Select ApplicationNode.js
  3. Select Datacenter with nearest location
  4. Add Application Name
  5. Add Server Name
  6. Select Server size depending on needs (for Node.js build, minimum recommended size is 2-4GB)

Node.js Single-Process Launch Step 1

  1. Click on "Launch" button and proceed with the payment process (trial or payment)

Once payment is completed, server with Node.js app provisioning will be initiated.

Wait for a while; it will take 5-7 minutes to create your server, configure, and deploy a high-performance web stack.

By default, on a new server you will get the following stack versions:

  • Node: 20.X+
  • npm: 10.X+
  • nvm: Latest
  • MariaDB: 10.6+ (optional)

Access Application Administration

Once your server is ready, in order to access the Node.js app, select "Apps" from the header menu to go to the Applications page.

On this page, you will see your application in active status.

Node.js Single-Process Launch Step 2

Click on it to navigate to "Application Administration""Access" section.

On this section, you will see:

  1. Application default access URL
  2. Server public address to point your custom domain to it

Node.js Single-Process Launch Step 3

Deploy Your Code

The next step is to deploy your code.

In order to deploy your code, navigate to the "Code Delivery" tab.

Here, on the first tab → "Git Deployment":

  1. Click on "Enable Git Integration"
  2. Copy SSH public key and add to your SCM provider (GitHub, GitLab)

Node.js Single-Process Deploy Step 1

  1. Copy your repo URL and add here in "Git Repository URL", select branch and "Clone Repository"

Node.js Single-Process Deploy Step 2

In this example, I'm going to deploy an example Node.js app:

[email protected]:jack-kloudbean/node-backend-api.git

Read the detailed guide on connecting git.

Once the repo is cloned, the next step is to run the deployment. Click on "Pull & Deploy".

Node.js Single-Process Deploy Step 3

Once you click it, it will initiate the build process automatically by doing the following at the backend:

Node.js Single-Process Deploy Step 4

  • Take latest repo pull
  • Enabling bean.conf for configuration like Node version, app source directory, and build command
  • Setting required Node version
  • Installing packages
  • Making build
  • Deploying it to web root directory

Updating/Adding Environment (.env) File

If you need to add or update .env file, you can access it using File Manager or optionally using shell.

Navigate to the third tab "FileManager" and click the "Launch FileManager" button to open it in a new tab.

Once you are in the file manager, in nodespm-src directory you can create a new file .env by clicking on "New file" from the left sidebar.

Give the file name and click "Create".

Node.js Single-Process Env Step 1

It will open a new file in the editor. Add your required environment variables. Like in this case, I'm going to add environment variables:

APP_URL=https://nodespm-232200304.kloudbeansite.com
DB_HOST=localhost
DB_NAME=kb_ms3u701nun
DB_USERNAME=kb_ms3u701nun
DB_PASSWORD=31vYF9Dc65gHbV742m

In order to get database access credentials, read the detailed guide on Viewing Database Credentials.

Node.js Single-Process Env Step 2

Once updated, click on the "Save" icon on the top right corner of the editor, and it will be saved.

note

Important: If your application has a custom app directory, then you have to update the bean.conf file as well accordingly.

After saving this, now when you run Build by CI/CD or by manually triggering "Pull & Deploy", your build process will start.

View Build Logs

Once your application is started, you can access it from the access URL:

"Application Administration"AccessAccess URL

If you are seeing 503, that means your application is not up and having some errors.

In order to view application logs:

  • You can view logs using File Manager
  • Or by SSH into server

Go to directory /home/admin/hosted-sites/<app_system_user>/app-logs

note

It is important to check your application logs if your site is responding with 503 gateway error. It shows that the application is not running.

In this directory, application logs are being added in the following log files:

  • app.info.log → Information logs
  • app.error.log → Error logs

You can open these files using File Manager to view the errors.

Node.js Single-Process App Logs

Restarting Node Application

If you want to restart your Node application, click "Pull & Deploy". It will build and deploy and will also restart your application.

note

With each deployment, the application also gets restarted. If you need to just restart it, you can run a build from "Pull & Deploy" or using the ADM tool.

Deployment Using ADM Tool (Application Deployment Manager)

Application Deployment Manager (ADM) is one of KloudBean's features which enables you to deploy your app quickly by just executing one command. It supports all Node and Python-based applications.

In order to perform deployment using the ADM tool, you have to access your server using shell.

Read the detailed guide on how to SSH server on KloudBean: Getting Server Access Credentials.

Once you are connected to the server, run the following ADM command:

sudo adm

or

sudo adm <app_system_user>

to directly execute for the required application.

Node.js Single-Process ADM Step 1

If you run this command without app_system_user, then you will have to select the app by providing its number in the prompt and click hit enter.

It will start the deployment process with the logs and progress detail on the shell screen.

Node.js Single-Process ADM Step 2

Next Steps