Skip to content

Commit 7ca7f0b

Browse files
committed
Update the systemd files to match the CLI and work for user level deployment.
#2
1 parent 3a0b4ac commit 7ca7f0b

File tree

2 files changed

+32
-54
lines changed

2 files changed

+32
-54
lines changed

tools/developer_tools/bely-mqtt-message-broker/examples/systemd/bely-mqtt.env

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@
44
# systemd service. Copy this to ~/.config/bely-mqtt/bely-mqtt.env and
55
# customize for your environment.
66

7+
8+
# Service Configuration
9+
# Path to the service executable
10+
# %h expands to user's home directory in systemd
11+
SERVICE_PATH=%h/.local/bin/bely-mqtt
12+
713
# MQTT Broker Configuration
8-
MQTT_BROKER=localhost
9-
MQTT_PORT=1883
14+
MQTT_BROKER_HOST=localhost
15+
MQTT_BROKER_PORT=1883
16+
MQTT_CLIENT_ID=
1017
MQTT_USERNAME=
1118
MQTT_PASSWORD=
19+
MQTT_TOPIC=
1220

1321
# Logging Configuration
1422
LOG_LEVEL=INFO
@@ -23,16 +31,9 @@ CONFIG_FILE=~/.config/bely-mqtt/config.json
2331
# Default: ~/.config/bely-mqtt/handlers
2432
HANDLERS_DIR=~/.config/bely-mqtt/handlers
2533

26-
# MQTT Topics to subscribe to
27-
# Default: bely/#
28-
MQTT_TOPICS=bely/#
29-
30-
# Optional: Apprise Notification Configuration
31-
# Path to Apprise notification config YAML
32-
APPRISE_CONFIG=~/.config/bely-mqtt/apprise_config.yaml
33-
34-
# Optional: Custom Python path for handlers
35-
# PYTHONPATH=/path/to/custom/handlers
34+
# BELY API Configuration
35+
BELY_API_URL=
36+
BELY_API_KEY=
3637

37-
# Optional: Enable debug mode
38-
# DEBUG=true
38+
# Additional environment file (optional)
39+
ENV_FILE=
Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,28 @@
11
[Unit]
22
Description=BELY MQTT Message Broker Framework
3-
Documentation=https://github.com/yourusername/bely-mqtt-message-broker
4-
After=network-online.target mosquitto.service
3+
After=network-online.target
54
Wants=network-online.target
65

76
[Service]
87
Type=simple
9-
User=%u
10-
Group=%u
11-
12-
# Working directory
13-
WorkingDirectory=%h/.config/bely-mqtt
14-
15-
# Environment variables
16-
Environment="PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin"
178
EnvironmentFile=%h/.config/bely-mqtt/bely-mqtt.env
18-
19-
# Service execution
20-
ExecStart=%h/.local/bin/bely-mqtt start \
21-
--handlers-dir %h/.config/bely-mqtt/handlers \
22-
--config %h/.config/bely-mqtt/config.json \
23-
--broker ${MQTT_BROKER:-localhost} \
24-
--port ${MQTT_PORT:-1883} \
25-
--topic "bely/#" \
26-
--log-level ${LOG_LEVEL:-INFO}
27-
28-
# Restart policy
299
Restart=on-failure
30-
RestartSec=10
31-
StartLimitInterval=60
32-
StartLimitBurst=3
33-
34-
# Logging
35-
StandardOutput=journal
36-
StandardError=journal
37-
SyslogIdentifier=bely-mqtt
10+
RestartSec=5
3811

39-
# Security
40-
NoNewPrivileges=true
41-
PrivateTmp=true
42-
ProtectSystem=strict
43-
ProtectHome=read-only
44-
ReadWritePaths=%h/.config/bely-mqtt/logs
45-
46-
# Resource limits
47-
LimitNOFILE=65536
48-
LimitNPROC=512
12+
# Service execution
13+
ExecStart=/bin/sh -c '${SERVICE_PATH} start \
14+
--handlers-dir ${HANDLERS_DIR} \
15+
--config ${CONFIG_FILE} \
16+
${MQTT_BROKER_HOST:+--broker-host=${MQTT_BROKER_HOST}} \
17+
${MQTT_BROKER_PORT:+--broker-port=${MQTT_BROKER_PORT}} \
18+
${MQTT_CLIENT_ID:+--client-id=${MQTT_CLIENT_ID}} \
19+
${MQTT_USERNAME:+--username=${MQTT_USERNAME}} \
20+
${MQTT_PASSWORD:+--password=${MQTT_PASSWORD}} \
21+
${MQTT_TOPIC:+--topic=${MQTT_TOPIC}} \
22+
${BELY_API_URL:+--api-url=${BELY_API_URL}} \
23+
${BELY_API_KEY:+--api-key=${BELY_API_KEY}} \
24+
${LOG_LEVEL:+--log-level=${LOG_LEVEL}} \
25+
${ENV_FILE:+--env-file=${ENV_FILE}}'
4926

5027
[Install]
51-
WantedBy=default.target
28+
WantedBy=default.target

0 commit comments

Comments
 (0)