System and Service Management

SmartServer 3.6 and prior releases use supervisorctl to manage custom applications that run as a service. This tutorial describes setting up a custom application as a service: Installing the Data Monitoring Application on Your SmartServer IoT.

Services on SmartServer 4.0 and higher releases use smartserverctl, a wrapper for systemd to manage components running as a service.

When updating from SmartServer 3.6 to 4.0 and higher, it is necessary to migrate from supervisorctl to smartserverctl for custom device types and services. This migration involves:

  • Creating unit files for each service to be migrated.

    • Placing files in the /lib/systemd/system/smartserver-<service>.service directory.

  • Installing services.

  • Starting services.

Once the migration process is completed, all of your services will be running using systemd.

This section describes how to migrate from supervisorctl to smartserverctl and consists of the following:

Create Unit Files

Prerequisite: SmartServer 4.0 or higher has been installed on your system.

Unit files are plain text files that contain configuration information about a service. They are used by systemd to control how and when a service is started and stopped.

You need to create unit files for each service that was supervised by supervisorctl and that you want to migrate to smartserverctl.

The example below is a unit file for a service called myService:

[Unit]
Description=myService
After=smartserver-core.service
Wants=smartserver-core.service
PartOf=smartserver-smartserver.service
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Type=exec
User=apollo
EnvironmentFile=/etc/apollo/environment
ExecStart=/var/apollo/data/myService/myService
Restart=always RestartSec=10 SyslogIdentifier=%N

[Install]
WantedBy=smartserver-smartserver.service

[Unit]
Description=myService
After=smartserver-core.service
Wants=smartserver-core.service
PartOf=smartserver-smartserver.service
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Type=exec
User=apollo
EnvironmentFile=/etc/apollo/environment
ExecStart=/var/apollo/data/myService/myService
Restart=always RestartSec=10 SyslogIdentifier=%N

[Install]
WantedBy=smartserver-smartserver.service

Create unit files for each service and place the files in the directory: /usr/lib/systemd/system/.

The format for each service unit file name is smartserver-<service>.service, where <service> is the name you want to use to refer to your service. The name is case-sensitive and should reflect the purpose of the service. For the example above, the file name would be smartserver-myService.service.

Install Services

Once unit files have been created for all of your services, you can install them by entering the following command:

For <service>, use the name of your service as defined in the unit file.

$ sudo smartserverctl enable smartserver-<service>.service

This command installs the services; they will automatically start up when the system boots.

Start Services

Once all of your services have been installed, you can start them by using the smartserverctl commands. For example, enter following command to start a service:

$ sudo smartserverctl start <service>

You can also use the smartserverctl command to check the status of your services. For example, enter the following command to check the status of a service:

$ sudo smartserverctl status <service>