lephisto / tesla-apiscraper

API Scraper for pulling Vehicle Statistics from the Tesla Owner API into an InfluxDB + Grafana Dashboards
GNU Lesser General Public License v3.0
365 stars 102 forks source link

about systemd service definition #74

Open ffllc opened 5 years ago

ffllc commented 5 years ago

Hi, i am a new user. I dont know how to set tesla-apiscraper for auto start after debian boot. I hope someone can help me. Thanks. I had test set a systemd service but it show Error

root@Debian:~# sudo systemctl status tesla.service

Sep 13 06:09:05 Debian systemd[1]: Started Tesla Service. Sep 13 06:09:06 Debian python3[1174]: Failed to initialize Owner API Sep 13 06:09:06 Debian systemd[1]: tesla.service: Main process exited, code=exit Sep 13 06:09:06 Debian systemd[1]: tesla.service: Unit entered failed state. Sep 13 06:09:06 Debian systemd[1]: tesla.service: Failed with result 'exit-code' lines 1-11/11 (END)

my service is:

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

[Service] Type=idle WorkingDirectory=/tesla-apiscraper ExecStart=/usr/bin/python3 apiscraper.py

[Install] WantedBy=multi-user.target

lephisto commented 5 years ago

Does the Service work if you start it manually?

egonzalezpozega commented 5 years ago

This one works for me on a debian based distro (armbian):

[Unit]
Description=Tesla Api Scraper
After=network.target
[Service]
Type=simple
User=bananapi
Group=bananapi
ExecStart=python3 /home/bananapi/tesla-apiscraper/apiscraper.py
Restart=always
Users=bananapi
WorkingDirectory=/home/bananapi/tesla-apiscraper
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target
rtega commented 5 years ago

Be careful to start it AFTER influxdb has started or it will exit immediately.