SystemService

Description

The SystemService object represents a system service and allows one to start() and stop() it and query its state through the running property. Even though it’s technically possible to control any systemd-based service by setting the name property to the appropriate systemd unit name, it’s recommended to use the services modeled by the inherited objects only:

› Inherits:Object
› Inherited by:DockerService, OpenVpnClientService, SshService, WebServerService

Properties

description

This property holds a user-defined description for the service. This property is not evaluated by the InCore framework.

› Type:String
› Signal:descriptionChanged()
› Attributes:Writable

enabled

This property holds whether the service is enabled. When enabled it’s started automatically whenever the application is started.

› Type:Boolean
› Default:true
› Signal:enabledChanged()
› Attributes:Writable

name

This property holds the name of the service, i.e. the systemd unit file name.

› Type:String
› Signal:nameChanged()
› Attributes:Writable

running

This property holds the current state of the service. If the service is running, this property is true, otherwise it’s false.

› Type:Boolean
› Default:false
› Signal:runningChanged()
› Attributes:Readonly

timeout

This property holds a timeout in milliseconds for service-related operations such as starting and stopping.

› Type:SignedInteger
› Default:30000
› Signal:timeoutChanged()
› Attributes:Writable

Methods

restart()

This method stops the service and starts it again after 5 seconds.

This method was introduced in InCore 2.7.

start()

This method starts the service and returns true on success.

› Returns:Boolean

stop()

This method stops the service and returns true on success.

› Returns:Boolean

Example

import InCore.Foundation 2.5

Application {

    Settings {
        property bool debugging: false;
    }

    System {
        SshService {
            enabled: debugging
        }

        WebServerService { }
    }
}