Error with service startup
See original GitHub issue[x] I’ve read the Troubleshooting Wiki, my problem is not described there and I am already using the specified minimum bluez version.
Describe the bug
Manually running sudo ./gateway.py -d
works fine and I can see correct output. This is when I try to start the service:
A couple issues here. Looks like the logger cannot load the yaml module. It also says something about start request repeated too quickly.
(.venv) pi@raspberrypi:~/bt-mqtt-gateway $ sudo systemctl status bt-mqtt-gateway
● bt-mqtt-gateway.service - Bluetooth MQTT gateway
Loaded: loaded (/etc/systemd/system/bt-mqtt-gateway.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-10 17:19:31 GMT; 980ms ago
Docs: https://github.com/zewelor/bt-mqtt-gateway
Main PID: 9799 (service.sh)
Tasks: 2 (limit: 881)
CGroup: /system.slice/bt-mqtt-gateway.service
├─9799 /bin/sh /home/pi/bt-mqtt-gateway/service.sh
└─9802 python3 ./gateway.py
Dec 10 17:19:31 raspberrypi systemd[1]: Started Bluetooth MQTT gateway.
Dec 10 17:19:32 raspberrypi service.sh[9799]: Traceback (most recent call last):
Dec 10 17:19:32 raspberrypi service.sh[9799]: File "./gateway.py", line 11, in <module>
Dec 10 17:19:32 raspberrypi service.sh[9799]: import logger
Dec 10 17:19:32 raspberrypi service.sh[9799]: File "/home/pi/bt-mqtt-gateway/logger.py", line 3, in <module>
Dec 10 17:19:32 raspberrypi service.sh[9799]: import yaml
Dec 10 17:19:32 raspberrypi service.sh[9799]: ModuleNotFoundError: No module named 'yaml'
(.venv) pi@raspberrypi:~/bt-mqtt-gateway $ sudo systemctl status bt-mqtt-gateway
● bt-mqtt-gateway.service - Bluetooth MQTT gateway
Loaded: loaded (/etc/systemd/system/bt-mqtt-gateway.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2020-12-10 17:19:32 GMT; 9s ago
Docs: https://github.com/zewelor/bt-mqtt-gateway
Process: 9799 ExecStart=/home/pi/bt-mqtt-gateway/service.sh (code=exited, status=1/FAILURE)
Main PID: 9799 (code=exited, status=1/FAILURE)
Dec 10 17:19:32 raspberrypi systemd[1]: bt-mqtt-gateway.service: Service RestartSec=100ms expired, scheduling restart.
Dec 10 17:19:32 raspberrypi systemd[1]: bt-mqtt-gateway.service: Scheduled restart job, restart counter is at 5.
Dec 10 17:19:32 raspberrypi systemd[1]: Stopped Bluetooth MQTT gateway.
Dec 10 17:19:32 raspberrypi systemd[1]: bt-mqtt-gateway.service: Start request repeated too quickly.
Dec 10 17:19:32 raspberrypi systemd[1]: bt-mqtt-gateway.service: Failed with result 'exit-code'.
Dec 10 17:19:32 raspberrypi systemd[1]: Failed to start Bluetooth MQTT gateway.
To Reproduce Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- See error
Expected behavior Service to start and stay running
Config
mqtt:
host: 192.168.**.**
port: 1883
ca_verify: False
client_id: bt-mqtt-gateway
availability_topic: lwt_topic
manager:
sensor_config:
topic: homeassistant
retain: true
topic_subscription:
update_all:
topic: homeassistant/status
payload: online
command_timeout: 35
workers:
toothbrush_homeassistant:
args:
autodiscovery_prefix: homeassistant
topic_prefix: toothbrush
devices:
quip:
name: Quip
mac: E9:*********
update_interval: 10
Debug gateway logs
(.venv) pi@raspberrypi:~/bt-mqtt-gateway $ sudo ./gateway.py -d
2020-12-10 17:25:17,859 INFO bt-mqtt-gw gateway.py:75:<module> - Starting
2020-12-10 17:25:17,866 DEBUG bt-mqtt-gw.mqtt mqtt.py:30:__init__ - Setting LWT to: lwt_topic
2020-12-10 17:25:26,001 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:107:register_workers - Added toothbrush_homeassistant worker with 10 seconds
interval and a 35 seconds timeout
2020-12-10 17:25:26,057 DEBUG bt-mqtt-gw.mqtt mqtt.py:117:callbacks_subscription - Subscribing to: toothbrush/update_interval
2020-12-10 17:25:26,061 DEBUG bt-mqtt-gw.mqtt mqtt.py:117:callbacks_subscription - Subscribing to: homeassistant/status
2020-12-10 17:25:26,091 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:173:update_all - Updating all workers
2020-12-10 17:25:26,505 DEBUG bt-mqtt-gw.workers.toothbrush_homeassistant toothbrush_homeassistant.py:102:handleDiscovery - Discovered new device: 1c:*********
.....
Server (please complete the following information):
- Linux raspberrypi 5.4.79+ #1373 Mon Nov 23 13:18:15 GMT 2020 armv6l
Additional context PiZero W
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Troubleshoot service startup permissions - Windows Server
Click Start, point to Administrative Tools, and then click Services. · Right-click the service that you want, and then click Properties. · Click ......
Read more >Fix Windows Services will not start in Windows 11/10
Fix Windows Service start error · 1] Check Services Startup type · 2] Troubleshoot in Clean Boot State · 3] Run SFC and...
Read more >Handle exception on service startup
I'm writing a series of Windows services. I want them to fail if errors are thrown during startup (in OnStart() method).
Read more >Workaround for Service Time-Out Error on Startup - Support
This article provides a workaround to an issue where the Royal Server service does not start due to a time-out error in Windows....
Read more >Application startup issue with Windows Services
Upon starting the application from Windows Services (from the windows server), if you receive an error like "Error2: The system cannot find the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had issues getting the service.sh started as well. I had to do #194 by comment out lines 3-9. Before doing that, when executing ./gateway.sh, I ran into btle.py errors, which was fixed with setcap…probably not very secure.
I also had to modify the bt-mqtt-gateway.service to add ExecStartPre=/bin/sleep 30 because the service failed to start when system was reboot. Probably needs some python service started first.
similar problem on rpi0w but starting it within docker. up until now i was not able to get out any logs from the container as it keeps restarting.