Alexa startet nicht als Dienst

Begonnen von dlehmann69, 26 Dezember 2016, 09:57:08

Vorheriges Thema - Nächstes Thema

MadMax-FHEM

#15
Zitat von: Trebor5 am 01 Februar 2017, 12:59:02
Hallo MadMax-Fhem

würde eine Neuinstallation unter dem pi user das Problem lösen ?

Habe da gar kein Augenmerk bei der Inst. drauf gelegt.

Kein Augenmerk drauf legen geht unter Linux eigentlich nicht.
Wenn etwas unter/als root getan wird, muss man sehr wohl "Augenmerk" drauf haben weil man muss ja erst mal root werden...


Ob es das Problem löst kann ich nicht sagen aber die Anleitungen und das Script gehen von den genannten Dingen aus:

Installation bzw. zumindest Start als User "pi" und im Verzeichnis /opt/fhem/alexa-fhem

config.json dann unter: /home/pi/.alexa

Allerdings musst du dafür sorgen, dass der User "pi" in /opt/fhem/log schreibberechtigt ist...

Ich habe unter /home/pi/alexa-fhem installiert, da passen alle Rechte.
Im Startscript dann noch die Pfade angepasst: /opt/fhem/alexa-fhem -> /home/pi/alexa-fhem und /opt/fhem/log -> /home/pi/alexa-fhem/log (oder wo immer du das Log haben willst) und nat. nicht vergessen den Pfad für die Logdatei (sollte er nicht existieren) anzulegen: mkdir /home/pi/alexa-fhem/log


Aber wenn es wirklich so ist/war, dass du ohne großes Augenmerk als/unter root installiert hast/arbeitest, dann vielleicht erst mal ein wenig mehr mit Linux etc. beschäftigen!! -> als gut gemeinten Rat verstehen...

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Wernieman

/root die Berechtigung 755 geben ... nicht optimal

Kannst Du nicht die Verzeichnisse verschieben?
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

MadMax-FHEM

Zitat von: Wernieman am 01 Februar 2017, 16:21:37
/root die Berechtigung 755 geben ... nicht optimal

Kannst Du nicht die Verzeichnisse verschieben?

Ah jetzt habe ich gefunden worauf sich das bezieht ;)

Jep: keine gute Idee!

Also noch mal als wirklich gut gemeinten Rat: Linux-Kenntnisse aufbauen!

Ist nicht wirklich schlimm...
...und bei öfterer Anwendung (die du ja jetzzt hast ;)  ) geht das ja automatisch, wenn man nicht (wie in deinem Fall) immer gleich mit den ganz ganz großen Kanonen schießt: als root arbeiten und jeder Berechtigung auf alles...

Sorgt zwar dafür, dass "augenscheinlich" alles geht aber bei sowas geht auch ganz schnell ganz ganz ganz viel kaputt!

Aber es ist open source und open mind ;)

Jeder wie er will...

Gruß und viel Spaß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Wernieman

BTW:
Anfängliche Unix-Kentrnisse sind auch für Windows nützlich. Dort wird meistens dieses per GUI überdeckt .... aber Gundlagen sind nicht zu überschätzen!

BTW2:
Nur mal am Rande:
Große Windows-Server werden heute auch wieder per Kommandozeile Administriert. Also "back to the root"
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

raimundl

Ich weiß nicht ob nun alle das Problem mit dem Autostart gelöst haben?

Daher möchte ich meine Lösung (Autostart hat bei mir auch nicht funktioniert) hier kurz aufzeigen:

Ein "sleep 7" am Beginn des scripts eingefügt und es hat bei mir funktioniert.

Ich nehme an, dass fhem bei mir etwas mehr Zeit zum Start braucht und daher eine Überschneidung entstanden ist.

LG
Homematic: Licht, Heizung, Alarm, Alexa ... auf einen RaspberryPi3+mit OS "Stretch" und RPI-RF-MOD mit piVCCU3 (HMCCU), ca. 40 HM Komponenten, alexa, MobileAlerts, Hue Ledstripes....

Wernieman

Darüber wurde schon an anderer Stelle Diskutiert.

Dem Start-Script vom FHEM erzählen, das er auf andere Elemente (wie z.B. Netzwerk) warten soll.

Je nachdem, ob DU fhem per init.d oder systemd startest, wird es anders eingerichtet. Wurde aber schon mehrfach diskutiert
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

bjbrill

Ich benutze Fhem auch auf einem Ubuntu 14.05 System und hatte genau die gleichen Probleme.
Nachdem ich den User von pi auf bjorn (mein User) gewechselt hatte und dann noch einen Pfad angepasst hatte
klappte es bei mir dann auch mit dem Autostart.

export NODE_PATH=$NODE_PATH:/usr/local/lib/n

Hier einmal die ganze Autostart von mir:
#!/bin/sh
### BEGIN INIT INFO
# Provides: alexa
# 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 alexa
# 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
export NODE_PATH=$NODE_PATH:/usr/local/lib/n
PID=`pidof alexa`
export ALEXAPATH="/opt/fhem/alexa-fhem"
export LOGPATH="/opt/fhem/log"
case "$1" in
start)
if ps -p $PID > /dev/null 2>&1; then
        echo "Alexa is already running"
        perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is already running"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status on"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
        su - "bjorn" -c "cd $ALEXAPATH;./bin/alexa > $LOGPATH/alexa-`date +%Y-%m`.log 2>&1 &"
        echo "Alexa starting"
        sleep 2
$0 status
fi
;;
stop)
if ! ps -p $PID > /dev/null 2>&1; then
        echo "Alexa is not running"
        perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is not running"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
        kill $PID
        echo "Alexa closed"
        perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa closed"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
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 "Alexa is running PID $PID"
        perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa running as PID $PID"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status on"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
        echo "Alexa is not running"
        perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is not running"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
        perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
echo "script done"
exit 0


Also bei mir hatte es geholfen.

Schöne Grüße Björn
Ubuntu-Server, Dect200, Jeelink, Unifi, ESP32, Alexa, Tasmota, zigbee2mqtt, OpenDTU.

hyper2910

Hallo,

ich komme einfach nicht weiter. Ich habe schon alles versucht.

./bin/alexa start
geht nicht.

ich mache es immer mit alexa start

jedoch kommt immer folgendes:

alexa start
Alexa starting
Alexa is not running
script done
script done


ich habe schon alles durch.

installiert habe ich unter User: pi

ich kann Starten unter Pi oder Root immer das gleiche.


kann mir jemand weiterhelfen?

Cubietruck mit FHEM, CUL V3 443MHz, 2 x CULV3 868MHz, Milights, Max Heizungssteuerung, Homematic, IT,

MadMax-FHEM

Zitat von: hyper2910 am 21 April 2017, 15:05:03

./bin/alexa start
geht nicht.

Klar, dass das nicht geht!

Entweder:

./bin/alexa

unter dem User der gedacht ist alexa-fhem zu starten (weil sonst die config.json nicht gefunden wird) und zwar wenn "man" im Installationsverzeichnis "steht"...
Also vielleicht mal so probieren...

Oder:

sudo /etc/init.d/alexa start

(sofern man init.d zum automatischen Starten nimmt)



Zitat von: hyper2910 am 21 April 2017, 15:05:03
ich mache es immer mit alexa start

jedoch kommt immer folgendes:

alexa start
Alexa starting
Alexa is not running
script done
script done


ich habe schon alles durch.

installiert habe ich unter User: pi

ich kann Starten unter Pi oder Root immer das gleiche.


kann mir jemand weiterhelfen?

Ich nehme mal an hier meinst du dann Variante "Oder" ;)

Wird ein alexa-fhem Log angelegt?
(wo steht im Script: /etc/init.d/alexa)

Wenn ja: was steht drin?

Wohin hast du alexa-fhem installiert?
Also Pfad.
Wo liegt die config.json?
Also auch Pfad... ;)

Welcher User soll denn alexa-fhem starten?
Also was steht im Script (/etc/init.d/alexa)?
Wenn du das Script einfach ohne Änderungen genommen hast, dann ist das wohl der User pi...


Zitat von: hyper2910 am 21 April 2017, 15:05:03
ich habe schon alles durch.

installiert habe ich unter User: pi

ich kann Starten unter Pi oder Root immer das gleiche.


kann mir jemand weiterhelfen?

Sehr aussagekräftige Informationen!
Bestimmt findet sich da leicht Hilfe ;)

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

hyper2910

Hallo Joachim,

vielen Dank.

ier mal die Infos, ich bin Schritt für Schritt der Anleitung gefolgt.

Wird ein alexa-fhem Log angelegt?
(wo steht im Script: /etc/init.d/alexa)
ja  ein Log wird angelegt! in /opt/fhem/log
Wenn ja: was steht drin?

ein eintrag:
/usr/bin/env: node: No such file or directory

Wohin hast du alexa-fhem installiert?

/opt/fhem/alexa-fhem

Wo liegt die config.json?

Home/pi/.alexa/


Welcher User soll denn alexa-fhem starten?
pi

Also was steht im Script (/etc/init.d/alexa)?
#!/bin/sh
### BEGIN INIT INFO
# Provides: alexa
# 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 alexa
# 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 alexa`
export ALEXAPATH="/opt/fhem/alexa-fhem"
export LOGPATH="/opt/fhem/log"
case "$1" in
start)
if ps -p $PID > /dev/null 2>&1; then
GNU nano 2.2.6 File: alxa GNU nano 2.2.6 File: alexa
#!/bin/sh
### BEGIN INIT INFO
# Provides: alexa
# Required-Start: $network $remote_fs $syslog
GNU nano 2.2.6 File: alexa
#!/bin/sh
### BEGIN INIT INFO
# Provides: alexa
# 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 alexa
# 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 alexa`
export ALEXAPATH="/opt/fhem/alexa-fhem"
export LOGPATH="/opt/fhem/log"
case "$1" in
start)
if ps -p $PID > /dev/null 2>&1; then
echo "Alexa is already running"
perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is already running"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status on"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
su - "pi" -c "cd $ALEXAPATH;./bin/alexa > $LOGPATH/alexa-`date +%Y-%m`.log 2>&1 &"
echo "Alexa starting"
sleep 2
$0 status
fi
;;
stop)
if ! ps -p $PID > /dev/null 2>&1; then
echo "Alexa is not running"
perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is not running"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
kill $PID
echo "Alexa closed"
perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa closed"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
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 "Alexa is running PID $PID"
perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa running as PID $PID"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status on"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
else
echo "Alexa is not running"
perl /opt/fhem/fhem.pl 7072 "setreading FHEM.Alexa.Status info Alexa is not running"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa.Status off"
perl /opt/fhem/fhem.pl 7072 "set FHEM.Alexa off"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
echo "script done"


Wenn du das Script einfach ohne Änderungen genommen hast, dann ist das wohl der User pi...
Cubietruck mit FHEM, CUL V3 443MHz, 2 x CULV3 868MHz, Milights, Max Heizungssteuerung, Homematic, IT,

MadMax-FHEM

Was kommt bei:

./bin/alexa

Wenn du als User pi im Verzeichnis /opt/fhem/alexa-fhem/ "stehst"...


Was kommt bei:

node -v

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

hyper2910

Hi,


mit ./bin/alexa

kommt
/usr/bin/env: node no such file or directory


node command not found


Cubietruck mit FHEM, CUL V3 443MHz, 2 x CULV3 868MHz, Milights, Max Heizungssteuerung, Homematic, IT,

MadMax-FHEM

Tja, dann ist wohl node nicht (richtig) installiert...
...und ohne das läuft alexa-fhem eben nicht.

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

hyper2910

ok, wie installiere ich die node denn richtig?
Cubietruck mit FHEM, CUL V3 443MHz, 2 x CULV3 868MHz, Milights, Max Heizungssteuerung, Homematic, IT,

MadMax-FHEM

Steht im Wiki...

Welches System überhaupt?

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)