8000 Systemd startup and disconnects · Issue #185 · owntracks/recorder · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Systemd startup and disconnects #185

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

Closed
bdub2 opened this issue Feb 5, 2017 · 9 comments
Closed

Systemd startup and disconnects #185

bdub2 opened this issue Feb 5, 2017 · 9 comments

Comments

@bdub2
Copy link
bdub2 commented Feb 5, 2017

I have not been able to get Systemd startup to work. I have tried with both non-tls and TLS with the same results. I am getting failed code exited status=15. If I restart it then it works. After it starts, I get constant Disconnected with Reason 0xE. Any help would be appreciated. Thanks

After sudo reboot:

pi@Plex-Media-Server-RPi:~ $ sudo systemctl status ot-recorder.service -l
â ot-recorder.service - OwnTracks Recorder
   Loaded: loaded (/etc/systemd/system/ot-recorder.service; enabled)
   Active: failed (Result: exit-code) since Sun 2017-02-05 17:24:35 CST; 1min 4s ago
  Process: 508 ExecStart=/usr/sbin/ot-recorder (code=exited, status=15)
 Main PID: 508 (code=exited, status=15)

Feb 05 17:24:34 Plex-Media-Server-RPi systemd[1]: Started OwnTracks Recorder.
Feb 05 17:24:35 Plex-Media-Server-RPi ot-recorder[508]: version 0.6.9 starting with STORAGEDIR=/var/spool/owntracks/recorder/store
Feb 05 17:24:35 Plex-Media-Server-RPi ot-recorder[508]: ot-recorder[508]: version 0.6.9 starting with STORAGEDIR=/var/spool/owntracks/recorder/store
Feb 05 17:24:35 Plex-Media-Server-RPi ot-recorder[508]: connecting to MQTT on 127.0.0.1:8883 as clientID ot-recorder-1 with TLS
Feb 05 17:24:35 Plex-Media-Server-RPi ot-recorder[508]: ot-recorder[508]: connecting to MQTT on 127.0.0.1:8883 as clientID ot-recorder-1 with TLS
Feb 05 17:24:35 Plex-Media-Server-RPi ot-recorder[508]: Unable to connect (15) [Unknown error.]: unknown reason.
Feb 05 17:24:35 Plex-Media-Server-RPi systemd[1]: ot-recorder.service: main process exited, code=exited, status=15/n/a
Feb 05 17:24:35 Plex-Media-Server-RPi systemd[1]: Unit ot-recorder.service entered failed state.

now restart and no more error code but disconnect errors

pi@Plex-Media-Server-RPi:~ $ sudo systemctl stop  ot-recorder.service
pi@Plex-Media-Server-RPi:~ $ sudo systemctl start ot-recorder.service
pi@Plex-Media-Server-RPi:~ $ sudo systemctl status ot-recorder.service -l
â ot-recorder.service - OwnTracks Recorder
   Loaded: loaded (/etc/systemd/system/ot-recorder.service; enabled)
   Active: active (running) since Sun 2017-02-05 17:26:14 CST; 7s ago
 Main PID: 1732 (ot-recorder)
   CGroup: /system.slice/ot-recorder.service
           ââ1732 /usr/sbin/ot-recorder

Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: ot-recorder[1732]: connecting to MQTT on 127.0.0.1:8883 as clientID ot-recorder-1 with TLS
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: connecting to MQTT on 127.0.0.1:8883 as clientID ot-recorder-1 with TLS
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: HTTP listener started on 192.168.0.202:8083
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: Using storage at /var/spool/owntracks/recorder/store with precision 7
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: ot-recorder[1732]: HTTP listener started on 192.168.0.202:8083
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: ot-recorder[1732]: Using storage at /var/spool/owntracks/recorder/store with precision 7
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: Disconnected. Reason: 0xE [unknown reason]
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: MQTT connection: rc=14 [Success] (errno=0; Success). Sleeping...
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: ot-recorder[1732]: Disconnected. Reason: 0xE [unknown reason]
Feb 05 17:26:14 Plex-Media-Server-RPi ot-recorder[1732]: ot-recorder[1732]: MQTT connection: rc=14 [Success] (errno=0; Success). Sleeping...
pi@Plex-Media-Server-RPi:~ $

@bdub2
Copy link
Author
bdub2 commented Feb 11, 2017

Does anyone know what status 15 is??

pi@RPi:~ $ sudo systemctl status ot-recorder.service -l
â ot-recorder.service - OwnTracks Recorder
Loaded: loaded (/etc/systemd/system/ot-recorder.service; enabled)
Active: failed (Result: exit-code) since Sun 2017-02-05 17:24:35 CST; 1min 4s ago
Process: 508 ExecStart=/usr/sbin/ot-recorder (code=exited, status=15)
Main PID: 508 (code=exited, status=15)

@jpmens
Copy link
Member
jpmens commented Mar 13, 2017

Judging by the diagnostics printed by Recorder, this are connectivity issues to your configured MQTT broker.

The code 15 you're seeing is from the mosquitto library:

MOSQ_ERR_UNKNOWN = 13,
MOSQ_ERR_ERRNO = 14,
MOSQ_ERR_EAI = 15,

MOSQ_ERR_EAI is defined as "Lookup error", but I don't know what that means. Browsing through libmosquitto I suggest EAI is returned when getaddrinfo() fails.

@scrimpys
Copy link
scrimpys commented Apr 3, 2017

Have the same problem. Am able to start the service manually when the system comes up but systemd fails to start it. Have added Restart=Always to the event config file but still doesn't come up by itself. Also note that I am using CloudMQT service. Waiting to get a response on this issue.

@indy2005
Copy link
indy2005 commented Apr 19, 2017

Hi,

I am having a similar issue. After booting, I have a 15 error, I have to run the service manually and it then works. I tried adding 'owntracks/#' manually to ot-recorder.service which I have read elsewhere as a possible solution.


pi@raspberrypi:~ $ service ot-recorder status
● ot-recorder.service - OwnTracks Recorder
   Loaded: loaded (/etc/systemd/system/ot-recorder.service; enabled)
   Active: failed (Result: exit-code) since Wed 2017-04-19 21:42:06 BST; 1min 19s ago
  Process: 445 ExecStart=/usr/sbin/ot-recorder owntracks/# (code=exited, status=15)
 Main PID: 445 (code=exited, status=15)
pi@raspberrypi:~ $ sudo systemctl start ot-recorder
pi@raspberrypi:~ $ service ot-recorder status
● ot-recorder.service - OwnTracks Recorder
   Loaded: loaded (/etc/systemd/system/ot-recorder.service; enabled)
   Active: active (running) since Wed 2017-04-19 21:44:00 BST; 2s ago
 Main PID: 1722 (ot-recorder)
   CGroup: /system.slice/ot-recorder.service
           └─1722 /usr/sbin/ot-recorder owntracks/#
pi@raspberrypi:~ $ 

My configuration is as follows:


OTR_STORAGEDIR="/var/spool/owntracks/recorder/store"
OTR_HOST="m20.cloudmqtt.com"
OTR_PORT=28659
OTR_USER="xxx"
OTR_PASS="xxx"
OTR_CAFILE="/etc/ssl/certs/ca-certificates.crt"
OTR_HTTPHOST="localhost"
OTR_HTTPPORT=8083
OTR_TOPICS="owntracks/+/+"

My ot-recorder.service file is below (default, not changed anything....do I need to?):

# /etc/systemd/system/ot-recorder.service

[Unit]
Description=OwnTracks Recorder

[Service]
Type=simple
User=owntracks
WorkingDirectory=/
ExecStart=/usr/sbin/ot-recorder

[Install]
WantedBy=multi-user.target

@koen01
Copy link
koen01 commented May 2, 2017

Could it be the ot-recorder service is started before network and/or mqtt service? Starting it after these fixes the problem ?

8000
@indy2005
Copy link
indy2005 commented May 2, 2017

Not sure how to control the startup sequence for the recorder dependencies?

@jpmens jpmens closed this as completed in 7234afd May 17, 2017
jpmens added a commit that referenced this issue May 17, 2017
- FIX: systemd launch and default topics in default files (#185)
- NEW: name of Lua revgeo function can be set in JSON payload
- NEW: support TLS PSK (#74)
- NEW: support for a Lua function to perform reverse Geo (#149)
- FIX: support for FREEBSD in Makefile/config.mk.in (#163)
- NEW: support for global store of geo fences (#178)
- NEW: support for CA_PATH and TLS client certificates
- FIX: setting http_port = 0 took CPU to unheard heights (#176)
- NEW: Add support for OSM using Leaflet, by Sven Klomp (#173)
- NEW: support for waypoints / geo-fences (WARNING: you must --initialize)
- FIX: built-in Web server serves apikey.js with application/javascript mime type (#168)
- FIX: Usage now shows missing OTR_BROWSERAPIKEY (#167)
@jpmens
Copy link
Member
jpmens commented May 17, 2017

I've spent ages trying to get this right and on the platforms I've tested it appears to work. Packages 0.7.1 are now out as is the docker image; I'll gladly hear from you all that it now works. :-)

@jpmens
Copy link
Member
jpmens commented May 17, 2017

So, even with 0.7.1 I notice some trouble which definitely stems from the fact that systemd is launching the Recorder before Mosquitto has a chance to be there; this happens also on very fast machines.

What I've experimented with is to add the following line to the unit file:

ExecStartPre=/bin/sleep 15
ExecStart=/usr/sbin/ot-recorder

The sleep is lousy, but if that's the only way it'll work ... This is now in production here on 3 different machines and after 12 reboots the Recorder always launches correctly.

Should you still have issues in 0.7.1 I would appreciate you experimenting with this setting; if it works for everybody, it'll be in 0.7.2

@jpmens jpmens reopened this May 17, 2017
@jpmens jpmens added the bug label May 17, 2017
@ezar
Copy link
ezar commented Jun 6, 2017

Works!

@jpmens jpmens closed this as completed in d4b4509 Oct 17, 2017
jpmens added a commit that referenced this issue Feb 12, 2018
- FIX: GPX exporter gets xmlns (#215)
- FIX: wait on start of systemd to allow Mosquitto to start (#185)
- FIX: s/json_remove_from_parent/_delete/g
- NEW: Add support for OwnTracks Pico by pretending `../pico` is a base topic (#205)
- UPD: rollback: cards are now once again stored at user/device/user-device.json (but map/table also uses user/user.json if it exists)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0