How to Fix “Unknown lvalue ‘StartLimitIntervalSec’ in systemd Unit Section” Error When Migrating from Upstart to systemd


2 views

When transitioning from Ubuntu 14 (using Upstart) to Ubuntu 16 (using systemd), service configuration files need significant restructuring. The error you're encountering indicates a version compatibility issue with systemd directives.

The error message:

[/lib/systemd/system/queue_server_two.service:3] Unknown lvalue 'StartLimitIntervalSec' in section 'Unit'

This occurs because the StartLimitIntervalSec directive was introduced in newer systemd versions (v230+) than what's available in Ubuntu 16's default installation.

Here's a corrected version of your service file that works with Ubuntu 16's systemd (v229):

[Unit]
Description=Data Server
After=network.target

[Service]
User=goldy
Group=goldy
Type=simple
WorkingDirectory=/opt/hold/data_server
ExecStart=/opt/hold/data_server/proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5
Restart=always
RestartSec=3
StartLimitInterval=0
LimitNOFILE=100000
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

1. Restart Logic:
- Upstart: Uses respawn
- systemd: Uses Restart=always with RestartSec

2. Start Limits:
- Older systemd versions use StartLimitInterval (seconds) instead of StartLimitIntervalSec

3. Resource Limits:
- systemd uses different syntax for limits (LimitNOFILE vs Upstart's limit nofile)

To implement the email notification functionality from your original Upstart config:

#!/bin/bash
# /usr/local/bin/data-server-notify.sh

case "$1" in
    start)
        echo "data server started at $(date +"%F %T") on $(hostname -f)" | \
        mailx -r "abc@host.com" -s "data server Started" "pqr@host.com"
        ;;
    stop)
        sleep 30
        ;;
esac

Then modify your service file to include:

ExecStartPost=/usr/local/bin/data-server-notify.sh start
ExecStopPost=/usr/local/bin/data-server-notify.sh stop

After creating/modifying your service file:

sudo systemctl daemon-reload
sudo systemctl start data_server
sudo systemctl status data_server
journalctl -u data_server -f  # For real-time logs

When moving from Ubuntu 14 (using Upstart) to Ubuntu 16 (using systemd), many developers encounter configuration translation issues. The error message you're seeing indicates a compatibility problem with the StartLimitIntervalSec directive in your systemd service file.

The "Unknown lvalue 'StartLimitIntervalSec'" error occurs because this directive was introduced in later versions of systemd. Ubuntu 16's default systemd version (229) doesn't support this parameter in the [Unit] section. The parameter exists but is named differently in older versions.

Here's the corrected version of your service file that should work on Ubuntu 16:

[Unit]
Description=Data Processing Server
After=network.target

[Service]
User=goldy
Group=goldy
Type=simple
WorkingDirectory=/opt/hold/data_server
ExecStart=/opt/hold/data_server/proc_server --init_file=../config/tree.init --port=8080 --dir=/data/hold/ --max_sec=2400 --max_mb=100 --active=5
Restart=always
RestartSec=3
StartLimitInterval=0
LimitNOFILE=100000
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

The main changes from your original file:

  • Removed StartLimitIntervalSec from [Unit] section
  • Added StartLimitInterval to [Service] section
  • Simplified the restart behavior configuration

For a more robust setup, consider adding these parameters:

TimeoutStartSec=30
TimeoutStopSec=30
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=data_server

After creating your service file, follow these steps:

sudo systemctl daemon-reload
sudo systemctl start data_server
sudo systemctl status data_server
journalctl -u data_server -f

To maintain equivalent functionality to your original Upstart configuration:

# For email notifications (alternative to post-start script)
ExecStartPost=/bin/sh -c 'echo "data server started at $(date +\"%%F %%T\") on $(hostname -f)" | mailx -r "abc@host.com" -s "data server Started" "pqr@host.com"'

# For post-stop delay (alternative to post-stop script)
ExecStop=/bin/sleep 30
ExecStopPost=/bin/systemctl stop data_server

If you need to maintain compatibility across different systemd versions, consider this pattern:

# For older systemd versions (pre-230)
StartLimitInterval=0

# For newer systemd versions (230+)
StartLimitIntervalSec=0
StartLimitBurst=5