Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


This section describes integrations with SmartServer 3.6 and prior. SmartServer 3.6 and prior uses supervisorctl to manage custom applications that run as a service. SmartServer 4.0 and higher uses smartserverctl to manage components that are running as a service. For integrations with SmartServer 4.0 and higher, see System and Service Management.

In this section, we will move the application developed in the previous section and set it up to run as a service on the SmartServer.   Here is what needs The following steps need to be done.performed:

  • Move the application and npm package files to a location on the SmartServer.
  • Install the application with npm.
  • Run the application from an SSH session.
  • Set the application up to run as a service under supervisorctl.


In this step, you will copy this the application to the folder /var/apollo/data/apps/point-monitor.

  1. Connect to the SmartServer as user apollo using winscp or other sftp client.

  2. Create a new folder called /var/apollo/data/apps/point-monitor as shown in the following screenshot.

  3. Copy these files from the point-monitor project directory to the folder you just created.


You have moved the application files (pointmonitor.js) along with the package.json file that describes the modules used by the application.  The following procedure only works if your SmartServer is connected to a network that can reach the internet.  This is required for npm to complete installation of dependent modules.

  1. Use putty.exe to connect to the ssh console as user apollo.

  2. Type: cd

    Enter the following command:

    Code Block
    cd /var/apollo/data/apps/point-
    Type: npm install 

  3. Enter the following command:

    Code Block
    npm install 

  4. After about 30 seconds, npm install will add 73 packages that comprise the mqtt.js, and collections.js modules used in this example.

  5. Run the application by

    typing: node pointmonitor.js 

    entering the following command:

    Code Block
    node pointmonitor.js 

    Image Modified

  6. The application will report operation as observed in the debugger to the console as shown above.

  7. Type <cntrl>+c to  to terminate the application.



up pointmonitor to Run as a Service

Many of the software modules that make up the SmartServer , are managed by supervisorctl.  In this section, we will create a conf file to run the pointmonitor.js application under supervisorctl.

  1. Type sudo nano

    Enter the following command:

    Code Block
    sudo nano /etc/supervisor/conf.d/pointmonitor.conf

  2. The following lines need to be added to this file:
    1. Type <cntrl>+o to write the file.
    2. Type <cntrl>+x to exit nano.

Code Block
command=node /var/apollo/data/apps/point-monitor/pointmonitor.js


Now you can reboot the SmartServer , and the pointmonitor.js application will run as a service in the following steps, you will understand how to . The steps that follow will confirm this operation.

  1. After the SmartServer rebootreboots, use putty.exe to connect to the SSH console.

  2. Type sudo

    Enter the following command:

    Code Block
    sudo supervisorctl

    Image Modified

    The pointmonitor application is show in the list of services running on your SmartServer along with the other services and modules that implement the SmartServer. 

  3. Type exit to return to the bash shell.

  4. If you want to monitor the standard output stream for the pointmonitor application running as a service,

    type tail

    then enter the following command:

    Code Block
    tail -f /var/log/supervisor/stdout-pointmonitor.log

    Image Modified

  5. You can use Use sudo supervisorctl to issue commands to stop and restart the pointmonitor application.

This application as written is reporting the results of every network variable poll request that is done by the lon:echlte engine.  Here are some explorations you should to try.:  

  1. You can control Control the state of the pointmonitor application by typing  typing  sudo supervisorctl and using supervisorctl commands like stop pointmonitor or start pointmonitor .

  2. Modify the monitorSpecs object array so the monitoring object for the points of interest generate data events on 'change' as shown in the following source code fragment.

    Code Block
    titlemonitorSpec Object Array set to Monitor on Change
    // Edit monitorSpecs object array according to your requirements to monitor the target data points of interest
    var monitorSpecs = [
            pid: "9FFFFF0501840460",
            nvList: [
                {ptPath: 'LightSensor/0/nvoLuxLevel', ms:{rate: 20, report: 'change', threshold:1, inFeedback:false}}, 
                {ptPath: 'TempSensor/0/nvoHVACTemp', ms:{rate: 20, report: 'change', threshold:0.1, inFeedback:false}},
                {ptPath: 'Switch/0/nvoValue', ms:{rate: 20, report: 'change', threshold:0, inFeedback:false}},
            pid: "9FFFFF0501840450",
            nvList: [
                {ptPath: 'LightSensor/0/nvoLuxLevel', ms:{rate: 20, report: 'change', threshold:1, inFeedback:false}}, 
                {ptPath: 'TempSensor/0/nvoHVACTemp', ms:{rate: 20, report: 'change', threshold:0.1, inFeedback:false}},
                {ptPath: 'Switch/0/nvoValue', ms:{rate: 20, report: 'change', threshold:1, inFeedback:false}},

  3. Observe how the application responds when the monitored devices are power down.  You will see monitor rate adjustments being made to leave only a single active point.  This type of behavior is most critical in a bandwidth limited channel, like a power line.  You could improve this application by leaving only a single actively polled point when a device goes down, and setting up the monitoring when the device health changes to "normal".

  4. Modify the application to work with your own LON devices.  

  5. Bonus points if you can modify the application to publish an update to ../rq/dev/lon/+/if/Lamp/0/nviValue   nviValue.

  6. This last point is a detail you need to understand.  An XIF file defines the implementation name for network variables on a devices interface.  When dealing with interfaces in the IAP/MQ, you need to use the names as defined by the functional block definition in the resource file.  For example, if you use the Open CT browser to browse the temperature sensor function block.  You will see the network variable listed by its program name as defined in the XIF file (nvoTemperature), but the topic to access this point in IAP/MQ is nvoHVACTemp as defined in the resource file as shown here.  The actual program name for the variable is part of the label property within the lon.cfg object within the datapoint object.

You have successfully run this application as a service.  You will need to remove or change the conf file extension of the /etc/supervisor/conf.d/pointmonitor.conf file to prevent the application from running as a service.