Skip to main content

systemd Service Configuration

DeepLX can be configured as a systemd service for automatic startup, restart on failure, and easy management on Linux systems.

Automatic Setup

The systemd service is automatically installed when using the installation script:
curl -fsSL https://raw.githubusercontent.com/OwO-Network/DeepLX/main/install.sh | bash
This will:
  • Download the systemd service file to /etc/systemd/system/deeplx.service
  • Reload the systemd daemon
  • Enable the service to start on boot
  • Start the DeepLX service

Manual Setup

If you prefer to set up the systemd service manually:
1

Create the service file

Download the official service file:
sudo wget -O /etc/systemd/system/deeplx.service https://raw.githubusercontent.com/OwO-Network/DeepLX/main/deeplx.service
Or create it manually:
/etc/systemd/system/deeplx.service
[Unit]
Description=DeepLX Service
After=network.target

[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx

[Install]
WantedBy=multi-user.target
2

Reload systemd daemon

sudo systemctl daemon-reload
3

Enable and start the service

sudo systemctl enable deeplx
sudo systemctl start deeplx
4

Verify the service is running

sudo systemctl status deeplx

Service File Breakdown

The DeepLX systemd service file contains the following sections:

[Unit] Section

[Unit]
Description=DeepLX Service
After=network.target
  • Description: Human-readable description of the service
  • After: Ensures DeepLX starts only after the network is available

[Service] Section

[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx
  • Type=simple: The process started is the main service process
  • Restart=always: Automatically restart the service if it crashes or stops
  • WorkingDirectory: Sets the working directory to /usr/bin/
  • ExecStart: Path to the DeepLX binary

[Install] Section

[Install]
WantedBy=multi-user.target
  • WantedBy: Specifies when the service should be started (at multi-user runlevel)

Customizing the Service

You can customize the service file to add environment variables, command-line options, or other configurations.

Adding Environment Variables

1

Edit the service file

sudo systemctl edit --full deeplx
2

Add environment variables

Modify the [Service] section:
[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
Environment="IP=0.0.0.0"
Environment="PORT=1188"
Environment="TOKEN=your_token_here"
Environment="DL_SESSION=your_session_here"
Environment="PROXY=http://proxy:8080"
ExecStart=/usr/bin/deeplx
Avoid storing sensitive tokens directly in the service file. Consider using systemd’s EnvironmentFile directive to load variables from a protected file.
3

Reload and restart

sudo systemctl daemon-reload
sudo systemctl restart deeplx

Using an Environment File

For better security, store environment variables in a separate file:
1

Create an environment file

sudo nano /etc/deeplx/config.env
Add your configuration:
IP=0.0.0.0
PORT=1188
TOKEN=your_token_here
DL_SESSION=your_session_here
PROXY=http://proxy:8080
2

Secure the file

sudo chmod 600 /etc/deeplx/config.env
sudo chown root:root /etc/deeplx/config.env
3

Update the service file

sudo systemctl edit --full deeplx
Add EnvironmentFile to the [Service] section:
[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
EnvironmentFile=/etc/deeplx/config.env
ExecStart=/usr/bin/deeplx
4

Reload and restart

sudo systemctl daemon-reload
sudo systemctl restart deeplx

Adding Command-Line Options

You can also configure DeepLX using command-line flags:
[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx --ip 0.0.0.0 --port 1188 --token mytoken
Command-line flags take precedence over environment variables.

Service Management Commands

Common systemd commands for managing the DeepLX service:
sudo systemctl start deeplx

Logging and Monitoring

Viewing Logs

DeepLX logs are managed by systemd’s journal:
sudo journalctl -u deeplx -f
Shows logs in real-time (similar to tail -f)

Service Status

Check the current status of the DeepLX service:
sudo systemctl status deeplx
This shows:
  • Service state (active/inactive)
  • Process ID (PID)
  • Memory usage
  • Recent log entries
  • Uptime information

Troubleshooting

Service Fails to Start

1

Check the service status

sudo systemctl status deeplx
2

View detailed logs

sudo journalctl -u deeplx -n 50
3

Verify binary exists and is executable

ls -l /usr/bin/deeplx
Should show -rwxr-xr-x permissions
4

Test the binary manually

/usr/bin/deeplx

Service Keeps Restarting

If the service is constantly restarting:
# Check restart count
sudo systemctl show deeplx | grep NRestarts

# View recent failures
sudo journalctl -u deeplx --since "1 hour ago"
Common causes:
  • Port 1188 already in use
  • Invalid environment variables
  • Missing dependencies
  • Incorrect file permissions

Port Already in Use

Check what’s using port 1188:
sudo lsof -i :1188
# or
sudo netstat -tulpn | grep 1188
Either stop the conflicting service or change DeepLX’s port using environment variables or command-line flags.

Advanced Configuration

Running as a Specific User

For better security, run DeepLX as a non-root user:
[Service]
Type=simple
User=deeplx
Group=deeplx
Restart=always
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx
Create the user first:
sudo useradd -r -s /bin/false deeplx

Resource Limits

Limit resources used by the DeepLX service:
[Service]
Type=simple
Restart=always
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx
MemoryLimit=512M
CPUQuota=50%

Restart Behavior

Customize restart behavior:
[Service]
Type=simple
Restart=on-failure
RestartSec=5s
StartLimitBurst=5
StartLimitIntervalSec=60s
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/deeplx
  • Restart=on-failure: Only restart on failures (not clean exits)
  • RestartSec: Wait 5 seconds before restarting
  • StartLimitBurst: Maximum 5 restart attempts
  • StartLimitIntervalSec: Within a 60-second window

File Locations

ComponentPathDescription
Service File/etc/systemd/system/deeplx.servicesystemd service configuration
Binary/usr/bin/deeplxDeepLX executable
Working Directory/usr/bin/Runtime working directory
Environment File/etc/deeplx/config.envOptional environment variables
Logsjournalctl -u deeplxsystemd journal

Build docs developers (and LLMs) love