Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd example #77

Open
KodinLanewave opened this issue Aug 14, 2024 · 3 comments
Open

systemd example #77

KodinLanewave opened this issue Aug 14, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@KodinLanewave
Copy link

KodinLanewave commented Aug 14, 2024

I just deployed your tool as a systemd service on Ubuntu. Since I have an example, this may be helpful for others:

config file is copied to /etc/default/renogy-bt
service file is copied to /lib/systemd/system/renogy-bt.service

Service file contents:

[Unit]
Description=Renogy Bluetooth Service
After=multi-user.target

[Service]
ExecStart=python3 /opt/renogy-bt/example.py /etc/default/renogy-bt
Restart=always
Type=simple

[Install]
WantedBy=multi-user.target

Works perfectly, logs to systemd logger under renogy-bt unit; to check logs, use journalctl -u renogy-bt
Don't forget to run systemctl daemon-reload after deploying all the files in the right places, then systemctl enable renogy-bt and systemctl start renogy-bt to enable at-boot and start the service.

Thanks for an excellent tool.

@smaluish
Copy link

smaluish commented Oct 6, 2024

Hi I was not able to get this working with more than 1 config file, are you able to point me in the right direction.

@cyrils cyrils added the documentation Improvements or additions to documentation label Nov 12, 2024
@nowcodingaway
Copy link

nowcodingaway commented Nov 21, 2024

EDIT: this solution doesn't quite work. Using the ExecStartPost means one of them times out. I have since split this into 2 service files, one for each device. However, this does still answer the original question of how to use a different config file (the battery-config.ini for example) so will leave the rest of this content here:

Here is my solution to running multiple configs from one systemd file. Appears to be working for me.

I am on a Pi 5. And running my python inside a venv/virtual environment.

The trick for me was using ExecStartPost. You can have as many of these as you want, then run one after the other following the initial ExecStart.


[Unit]
Description=Renogy Bluetooth Service
After=multi-user.target

[Service]
ExecStart=/home/admin/Renogy/venv/bin/python /home/admin/Renogy/example.py battery-config.ini
ExecStartPost=/home/admin/Renogy/venv/bin/python /home/admin/Renogy/example.py controller-config.ini
Restart=always
Type=simple

[Install]
WantedBy=multi-user.target

@nowcodingaway
Copy link

I am not 100% sure this is working as expected and think it may be causing time outs.

For now, I am going to split this into 2 individual services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants