Skip to end of metadata
Go to start of metadata

Below is a simple demonstration of deploying a small web application to a SmartMacine web server.

In this topic:

At a Glance

This topic shows you how to write a simple web server in Node.js.

Writing a Node.js Application

Use the following instructions to write a simple web server called "Hello, world!" in Node.js.

  1. Create a directory on your SmartMachine:
  2. Create a server.js file and write the following:
  3. Save the file to ~/hello-world/server.js.
    You can get copy of this from here.
  4. Start the server:
  5. Test the server by pointing a browser to the public IP of your SmartMachine.

Define the Service

You can use the Service Management Facility (SMF) to manage services you define. A service in Solaris is a first-class citizen and is associated with a manifest file that defines it. The following instructions use SMF commands to define and start a "Hello, world!" service.

  1. Download the example "Hello, world!" manifest file and add it to the system configuration with the following:
    A copy of the example "Hello, world!" manifest file is here.
    If you clone the git repo, you can use SMF to grab the manifest from there instead.
  2. Start the Service:
    You can use disable to stop the service.
  3. Point a web browser to the public IP of your SmartMachine.

If the browser renders a "Hello, world!" page, congratulations! Your Node.js web server is running successfully!


A service in Solaris is associated with a log file of the same name. In this case, the log file is stored at /var/svc/log/site-node-hello-world-service:default.log. If a problem with a service occurs, you can troubleshoot it by looking at the service log. For example, you can view the last few log messages like this:

SMF will attempt to restart a service if it stops unexpectedly. However, if the service keeps crashing, SMF will place the service in "maintenance" mode. For example:

If this happens, ensure the site is working if you start the service manually. This uncovers most problems.

For this command, sudo is required because "Hello, world!" is listening on port 80.

You can also get information about a service by using the svcs command. For example, if "Hello, world!" thrashes itself into maintenance mode, you might see this:

Once you fix whatever it is that is preventing the service from starting properly, you can restart it by doing the following:

Once a service goes into maintenance mode, you must disable it before you can re-enable it.

At this point, the log should look like this:

You can then test your site by pointing a web browser at your domain or curl

node node Delete
service service Delete
web web Delete
server server Delete
application application Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.