Node.js Hosting Overview

Enabling Node.js Hosting

1. In order to enable the Node.js hosting for your users, you should add the appropriate cartridge using your JCA panel. For that navigate to the Jelastic Templates repository and find the Node.js cartridge in the list.

Note that we provide a basic cartridge version. If you would like to extend it or add some additional features, fork Node.js cartridge repository and make all the changes needed.

2. Add and publish the desired Node.js cartridge via JCA as it is described in the Add Cartridge document.

3. Then navigate to your JCA > System settings > User Interface.

Find the ENGINE_TYPES parameter and ensure “nodejs” is added to the list of available programming languages. If you use several programming languages, then just enumerate them comma separated.

Note: In case you would like to enable all the languages supported by Jelastic (i.e. Java, PHP, Ruby, Python and Node.js) for your users, you can state “*” value instead of comma separated list.

4. After that all users will see a Node.js tab near Java, PHP, Ruby and Python in the Environment topology window.

Node.js Application Server

Using NodeJS app server you can deploy and run any required application within your Node.js environment. The number of servers can be scaled horizontally up and down via the topology wizard.

With a help of Jelastic automated tools it is possible to deploy your application just in a few minutes. The detailed workflow is described in the Deploy Node.js Project via Archive/URL and Deploy Node.js Project via GIT/SVN docs.

Version Management

Jelastic provides 0.10 Node.js engine version by default.

Log Files

Jelastic makes the node.log file available for Node.js. It can be seen by pressing the Log button next to the Node.js application server in the environment.

Packages & Processes Management

Each newly created NodeJS server contains the embedded npm (Node Package Manager) development tool. It has a lof of features and possibilities, greatly facilitating the process of your project’s management, e.g. resolving dependencies, running scripts, managing application lifecycle, interacting with other tools, etc. We’ll describe several of them in more details.

Npm can be used for managing the additional modules and packages, required for your project, as well as for installation of the ready-to-use applications, available within npm registry.

There are two ways for downloading and installing the necessary Node.js packages:

  • specify them within the package.json file, located in the root of your project. The required package should be set inside the dependencies file section, using a hash of its name to version range. See more details here.

    This JSON file will be read by the deployment script in order to automatically install these modules with the help of npm.

In case you need to install some additional modules to the already deployed application, restart the NodeJS server after they were specified in the abovementioned file.

  • connect to your container via SSH and operate with the following commands:

    npm search {package_name} - to search for a necessary module by its name (or name part)
    npm instal {package_name} - to install the necessary module
    npm uninstall {package_name} - to remove the previously installed module
    npm update {package_name} - to update the specified module to the latest version
    npm ls installed - to see the set of already installed packages

    Using additional commands and their attributes you can also specify the desired module version, configure relative dependencies resolving, show details on installed modules, etc. To find out more details on commands you can use, navigate to the npm user docs.

You also have an ability to manage the lifecycle processes of your application with the help of the same package.json file, e.g. what operations should be executed before or after the application is started, updated, etc. The required formatting and parameters can be found in the appropriate instruction.