muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.3k stars 324 forks source link

How to start the service with a --bind url ? #294

Closed Zykino closed 4 years ago

Zykino commented 4 years ago

I followed the Watchdogs and the Troubleshooting docs to know about both of this functions. Starting with systemctl start beehive works but is not enabled at startup. Journalctl is telling me there are too much restart. And just before I have an error telling me that the bind did not work on the IP I defined.

I’m on a Raspberry PI, WIFI.

rubiojr commented 4 years ago

Happy to help.

I'll need to have a look at your systemd service configuration and service logs with beehive --debug enabled, so I can try to figure out what's going on. Beehive's binary version or ref/commit SHA may also help.

Could you add those to a gist after removing any sensitive info and link them here?

rubiojr commented 4 years ago

Is your Raspberry running Raspbian?

Zykino commented 4 years ago

I will come back later with the propers infos/logs. Yes I'm using Raspbian, I'm using the latest release: beehive_0.4.0_Linux_armv6.tar.gz (extracted in to /opt) The systemd's configuration is the one I found here https://github.com/muesli/beehive/blob/master/docs/watchdog.md. I did try to add After=network-online.target in the [Unit] section but I don't know systemctl's syntax so I did not try more.

rubiojr commented 4 years ago

@Zykino is the intention to bind to a specific IP because you have multiple and you only want to listen on a specific one?

Zykino commented 4 years ago
$ cat /etc/systemd/system/beehive.service 
[Unit]
Description=Beehive with Systemd's watchdog
After=network-online.target

[Service]
Type=simple
ExecStart=/opt/beehive_0.4.0_Linux_armv6/beehive --debug --config /etc/beehive.conf --bind "192.168.1.52:8181" --canonicalurl "http://192.168.1.52:8181"
Restart=on-failure
WatchdogSec=30s

[Install]
WantedBy=multi-user.target

journalctl -u beehive > beehive.log

I’m using the bind and canonicalurl options to access the admin interface from my PC, because on the PI it is not very practical.

rubiojr commented 4 years ago

@Zykino sounds like a service ordering issue. You have at least two options:

Add Wants=network-online.target to your [Unit] section. https://raspberrypi.stackexchange.com/questions/88179/service-failing-to-wait-for-internet-connection explains why.

Another option is to use --bind 0.0.0.0:8181 to bind to all IPs.

So:

[Unit]
Description=Beehive with Systemd's watchdog

[Service]
Type=simple
ExecStart=/opt/beehive_0.4.0_Linux_armv6/beehive --debug --config /etc/beehive.conf --bind "0.0.0.0:8181" --canonicalurl "http://192.168.1.52:8181"
Restart=on-failure
WatchdogSec=30s

[Install]
WantedBy=multi-user.target

or

[Unit]
Description=Beehive with Systemd's watchdog
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/opt/beehive_0.4.0_Linux_armv6/beehive --debug --config /etc/beehive.conf --bind "192.168.1.52:8181" --canonicalurl "http://192.168.1.52:8181"
Restart=on-failure
WatchdogSec=30s

[Install]
WantedBy=multi-user.target

Let us know if that helps, we'll improve the documentation with the result.

Zykino commented 4 years ago

So the option to add Wants did not work, but setting the bind to 0.0.0.0 did worked. And I am able to access it from my PC.

I could close the issue or do you want me to do more test on to make the ordering thing work ?
Maybe I let you add this to the documentation somewhere and close the issue. I did not understood that we could set the options like that to be able to access the site from an other PC.

rubiojr commented 4 years ago

So the option to add Wants did not work, but setting the bind to 0.0.0.0 did worked. And I am able to access it from my PC.

Which Raspbian release are you using? Buster? Stretch? Adding Wants fixed ordering for me using Buster.

I could close the issue or do you want me to do more test on to make the ordering thing work ? Maybe I let you add this to the documentation somewhere and close the issue. I did not understood that we could set the options like that to be able to access the site from an other PC.

Yeah, all good. I'll update the docs to mention something like this could be required when using --bind and Systemd.

Thanks!

Zykino commented 4 years ago

I don’t know, installed it begining of march. But since it is a PI 4 and saw how to pass the system to 64bits I wanted to try. So it run on aarch64. I did not notice bugs until maybe this one on either systemd or beehive armv6 on aarch64? Not sure, not caring much since the other method is working.

rubiojr commented 4 years ago

Thank you!

Zykino commented 4 years ago

To be honest I needed to ask on IRC to (more or less) understand the difference between --bind and --canonicalurl. I did not really understand, maybe because I’m not familiar with the specialized network vocabulary in english ^^'.

rubiojr commented 4 years ago

@muesli how bad would it be to set the canonical URL to something like http://<bind-ip>[:<port>] when --bind is specified, so --canonicalurl is not always required for use cases like this one?