ข้ามไปยังเนื้อหาหลัก
Version: TOS 7

Systemd Service Specification

The service unit ID comes from config.ini.system_id:

{
"system_id": "<system_id>"
}

The final system service must be:

<system_id>.service

Retained within the application installation directory:

/usr/local/<app_id>/init.d/<system_id>.service

Standard Service File:

Standard Service File (with security hardening):

[Unit]
Description=<service_description>
After=network.target
StartLimitBurst=5
StartLimitIntervalSec=60

[Service]
Type=simple
User=<appid>
Group=<appid>
WorkingDirectory=/usr/local/<appid>
ExecStart=/usr/local/<appid>/bin/<binary_name>
EnvironmentFile=/usr/local/<appid>/<appid>.env
TimeoutStartSec=30
TimeoutStopSec=10
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/<appid> /var/log/<appid>
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Systemd Directive Reference:

DirectiveValueRequiredDescription
User<appid>✅ YesRun the service as a dedicated non-root user
Group<appid>✅ YesRun the service with a dedicated group
WorkingDirectory/usr/local/<appid>✅ YesWorking directory for the service
NoNewPrivilegestrue✅ YesPrevent privilege escalation
ProtectSystemstrict✅ YesMount /usr, /boot, /etc as read-only
ProtectHometrue✅ YesHide the /home directory
TimeoutStartSec30✅ YesService startup timeout (seconds)
TimeoutStopSec10✅ YesGraceful stop timeout (seconds)
AmbientCapabilitiesCAP_NET_BIND_SERVICEConditionalOnly needed when binding to ports below 1024
ReadWritePaths/usr/local/<appid>/data /usr/local/<appid>/logs✅ YesExplicitly declare writable paths (the application's own data and log directories)
LimitNOFILE65536RecommendedFile descriptor limit
StartLimitBurst5OptionalMaximum restart attempts within the interval (set according to your needs)
StartLimitIntervalSec60OptionalRestart limit interval in seconds (set according to your needs)
Restarton-failureOptionalWhen to restart the service (e.g., always, on-failure, no). The App Center executes the restart policy defined here
RestartSec10OptionalTime to wait before restarting the service (seconds)
Important

Developers may configure Restart= and RestartSec= in the service file according to their application's requirements. The App Center will execute the restart policy according to these developer-defined configurations. To prevent runaway crash loops, configure StartLimitBurst= and StartLimitIntervalSec= as needed.