Hallo zusammen.
Meinen RPi habe ich schein eine ganze Weile laufen und auch die Homebridge (mit up's & down's und restore Backup) eigentlich schon lange laufen. Manuell aufgesetzt.
Der RPi ist so eingerichtet, nach irgendwelchen Anleitungen die ich damals Schritt für Schritt befolgt habe, dass er jede Stunde neu startet und beim Start homebridge lädt.
Soweit ich das nachvollziehen kann, habe ich das damals über init.d gemacht.
Jetzt fällt mir immer mal wieder auf, dass nach einem automatischen Neustart homebridge nicht reagiert. Prüfe ich das mit sudo /etc/init.d/homebridge status wird mir das auch bestätigt "
Homebridge is not running". Starte ich homebridge zur Überprüfung mit homebridge läuft alles ohne Fehler durch. Auch sudo /etc/init.d/homebridge start klappt. Wobei mir angezeigt wird
Homebridge starting
Homebridge is not running
Was etwas verwirrend ist. Prüfe ich den Status dann aber nochmal, stimmt alles.
Homebridge is running PID 11506
Mit systemctl status homebridge bekomme ich was angezeigt, was ich schon wieder mit meiner Unkenntnis nicht verstehe.
? homebridge.service - LSB: Start daemon at boot time for homebridge
Loaded: loaded (/etc/init.d/homebridge)
Active: active (exited) since So 2017-06-11 15:26:52 CEST; 39min ago
Process: 520 ExecStart=/etc/init.d/homebridge start (code=exited, status=0/SUCCESS)
Aber soweit, so gut. Wenn nicht manchmal eben homebridge wohl nach dem Neustart nicht geladen wird. Starte ich den RPi sudo reboot ist dann bei dem reboot die homebridge wieder geladen. Ich kann nicht so wirklich nachvollziehen warum es mal geht und mal nicht.
1) Daher meine Überlegung, ob es vielleicht an der init.d Konfiguration liegen könnte?
2) Wäre es besser auf systemd zu wechseln?
3) Ich möchte ungern nochmal den ganzen RPi bzw. homebridge umkrempeln. Es läuft ja alles soweit ganz gut und stabil.
4) Wenn doch auf systemd wechseln sinnvoll ist, wie kann ich init.d zurück abwickeln, also ausschalten?
5) Und gibt es eine einfache step-by-step Anleitung wie systemd autostart dann einzurichten ist. Hier unter den Anleitungen konnte ich nichts finden.
Um Nachsicht wird gebeten, falls ich bekloppte fragen stelle. ![]()
Vorab vielen Dank.
Und hier mal alles was ich irgendwann, irgendwie mit step-by-step Anleitungen gebastelt habe. ![]()
Einziger User "pi"
config.json liegt in /home/pi/.homebridge
homebridge in /user/local/bin
/etc/init.d/homebridge (siehe Code)
Raspberry Pi 2 Model B Rev 1.1
OS: Raspbian GNU/Linux 8 (jessie)
Kernel: Linux 4.9.30-v7+
/etc/init.d/homebridge
#!/bin/sh
### BEGIN INIT INFO
# Provides: homebridge
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time for homebridge
# Description: Enable service provided by daemon.
### END INIT INFO
export PATH=$PATH:/usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
PID=`pidof homebridge`
case "$1" in
start)
if ps -p $PID > /dev/null 2>&1; then
echo "Homebridge is already running"
else
su - pi -c "homebridge > /dev/null 2>&1 &"
echo "Homebridge starting"
$0 status
fi
;;
stop)
if ! ps -p $PID > /dev/null 2>&1; then
echo "Homebridge is not running"
else
kill $PID
echo "Homebridge closed"
fi
;;
restart)
if ! ps -p $PID > /dev/null 2>&1; then
$0 start
else
$0 stop
$0 start
fi
;;
status)
if ps -p $PID > /dev/null 2>&1; then
echo "Homebridge is running PID $PID"
else
echo "Homebridge is not running"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
Alles anzeigen
sudo crontab -e
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
15 * * * * /sbin/shutdown -r
Alles anzeigen
sudo nano /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/etc/init.d/tightvncserver start
/etc/init.d/homebridge start
exit 0
Alles anzeigen