🔐 add EnvironmentFile to systemd service

This commit is contained in:
Finn Christiansen 2024-10-08 22:15:04 +02:00
parent 5900fec8ff
commit 9b79b004e5
3 changed files with 3 additions and 1 deletions

View file

@ -5,3 +5,4 @@ INFLUXDB_BUCKET="electricity"
INFLUXDB_ENABLED=True INFLUXDB_ENABLED=True
FLASK_APP_URL="http://localhost/impulses" FLASK_APP_URL="http://localhost/impulses"
FLASK_APP_ENABLED=True FLASK_APP_ENABLED=True
SENSOR_PIN=27

View file

@ -21,7 +21,7 @@ if os.getenv("INFLUXDB_ENABLED", False).lower() == "true":
client = influxdb_client.InfluxDBClient(url=url, token=token, org=org) client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
write_api = client.write_api(write_options=SYNCHRONOUS) write_api = client.write_api(write_options=SYNCHRONOUS)
SENSOR_PIN = 27 SENSOR_PIN = os.environ.get("SENSOR_PIN")
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setup(SENSOR_PIN, GPIO.IN) GPIO.setup(SENSOR_PIN, GPIO.IN)

View file

@ -4,6 +4,7 @@ Description=PowerMeter Service
[Service] [Service]
Type=simple Type=simple
User=root User=root
EnvironmentFile=/etc/powermeter-environment
ExecStart=/usr/local/bin/powermeter.py ExecStart=/usr/local/bin/powermeter.py
Restart=always Restart=always
RestartSec=30 RestartSec=30