Skip to content

Add a systemd env file that defines runtime variables#397

Open
ezio-melotti wants to merge 7 commits into
masterfrom
systemd-envfile
Open

Add a systemd env file that defines runtime variables#397
ezio-melotti wants to merge 7 commits into
masterfrom
systemd-envfile

Conversation

@ezio-melotti

Copy link
Copy Markdown
Collaborator

This PR adds an environment file which contains runtime variables to be used by systemd services, as described in:

Currently it only defines the VENV_PY variable, but by introducing the .env file and adding it to the services units, it allows us to easily inject more variables when needed. The username and working dir are still hardcoded, but that can be fixed in a separate PR.

@ezio-melotti
ezio-melotti requested a review from Copilot July 10, 2026 15:20
@ezio-melotti ezio-melotti self-assigned this Jul 10, 2026
@ezio-melotti ezio-melotti added systemd Issues related to systemd simoc-sam Issues relates to the simoc-sam.py script labels Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a generated environment file (.env) intended for use by systemd units, so runtime-configurable values (starting with VENV_PY) can be injected without hardcoding them directly in each service unit.

Changes:

  • Add write_service_env_file() to generate simoc-sam/.env and call it during update() and setup_systemd_unit().
  • Update multiple configs/*.service unit files to read VENV_PY from EnvironmentFile= and use it in ExecStart=.
  • Add .env to .gitignore.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
simoc-sam.py Adds .env generation and hooks it into update/unit setup flows.
configs/sqlwriter.service Switches Python executable to ${VENV_PY} loaded from .env.
configs/siobridge.service Switches Python executable to ${VENV_PY} loaded from .env.
configs/sensor-runner@.service Switches Python executable to ${VENV_PY} loaded from .env.
configs/display-runner@.service Switches Python executable to ${VENV_PY} loaded from .env.
configs/csvwriter.service Switches Python executable to ${VENV_PY} loaded from .env.
.gitignore Ignores the generated .env file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread simoc-sam.py
Comment thread configs/sqlwriter.service Outdated
Comment thread configs/siobridge.service Outdated
Comment thread configs/sensor-runner@.service Outdated
Comment thread configs/display-runner@.service Outdated
Comment thread configs/csvwriter.service Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.

Comment thread simoc-sam.py Outdated
Comment thread configs/sqlwriter.service
Comment thread configs/siobridge.service
Comment thread configs/csvwriter.service
Comment thread configs/sensor-runner@.service
Comment thread configs/display-runner@.service

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Comment thread simoc-sam.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Comment thread simoc-sam.py
Comment thread simoc-sam.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

simoc-sam Issues relates to the simoc-sam.py script systemd Issues related to systemd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants