Page 1 sur 1

demarrage domoticz

Publié : 16 nov. 2023, 23:18
par knasson
Bonsoir
depuis quelque temps je rencontre des soucis de démarrage de Domoticz.
le log du status domoticz est le suivant:
root@raspberrypi:/home/kan/domoticz# systemctl status domoticz
● domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated)
Active: active (running) since Thu 2023-11-16 23:06:44 CET; 2min 48s ago
Docs: man:systemd-sysv-generator(8)
Process: 7868 ExecStart=/etc/init.d/domoticz.sh start (code=exited, status=0/SUCCESS)
Tasks: 2 (limit: 3721)
CGroup: /system.slice/domoticz.service
├─7848 sh -c curl -s 'http://192.168.1.38:8080/json.htm?type=devices&rid=597'
└─7849 curl -s http://192.168.1.38:8080/json.htm?type=devices&rid=597

Nov 16 23:06:44 raspberrypi systemd[1]: Starting LSB: Home Automation System...
Nov 16 23:06:44 raspberrypi domoticz.sh[7868]: 2023-11-16 23:06:44.332 Status: Domoticz V2023.1 (c)2012-2023 GizMoCuz
Nov 16 23:06:44 raspberrypi domoticz.sh[7868]: 2023-11-16 23:06:44.332 Status: Build Hash: f9b9ac774, Date: 2023-02-14 15:06:40
Nov 16 23:06:44 raspberrypi domoticz.sh[7868]: 2023-11-16 23:06:44.332 Status: Startup Path: /home/kan/domoticz/
Nov 16 23:06:44 raspberrypi domoticz.sh[7868]: domoticz: Domoticz is starting up....
Nov 16 23:06:44 raspberrypi domoticz[7873]: Domoticz is starting up....
Nov 16 23:06:44 raspberrypi systemd[1]: Started LSB: Home Automation System.
Quand je teste si domoticz est dans les process démarrés avec ps -e | grep domoticz je ne le vois pas et rien ne s'affiche lorsque j'interroge l'adresse du serveur domoticz.
'Je demarre en ssh sur un raspberry pi, je n'ai pas fait la dernière mise a jour (de juillet 2023))
je ne comprends pas ce qu'il se passe...Pouvez vous m'aider?

Re: demarrage domoticz

Publié : 17 nov. 2023, 14:19
par Keros
Tu peux nous préciser la version de ton OS et la version de DomoticZ ?

Tu es avec une carte SD ou un disque SSD?

Qu'est-ce qu'il se passe au démarrage du Pi ? DomoticZ se lance ?

Re: demarrage domoticz

Publié : 17 nov. 2023, 17:34
par knasson
Ma version c'est 2023-1
Oui j'ai un disque SSD
En général Domoticz ne se lance pas ..toujours.
Le dernier démarrage réussi j'ai fait "reboot", puis
"systemctl status domoticz"
la je vois "domoticz running" mais dans les fait il n'est pas démarré car il n'est pas dans la liste des process et que l'interface ne répond pas.
puis
"systemctl stop domoticz"
puis
"systemctl start domoticz
".et la miracle il démarre.
depuis j'ai mis monit en espérant qu'il me redémarre Domoticz automatiquement en cas de coupure ou autre.

Mais je patauge car je ne comprend pas...

Re: demarrage domoticz

Publié : 17 nov. 2023, 18:08
par lost
knasson a écrit : 17 nov. 2023, 17:34 En général Domoticz ne se lance pas ..toujours.
Au vu du status donné, cela paraissait lancé. Maintenant, attention à regarder les heures car si lancé en service systemd va déjà relancer lui-même automatiquement si le process s'arrête rapidement suite à erreur. Bref, possible de voir un status OK et un ps ne donnant rien si on tombe mal!

Il faut à mon sens modifier le lancement et ajouter une option "-log /tmp/domoticz.txt" par exemple, afin de logger dans un ficher texte qu'on peut consulter et montrera des redémarrages et idéalement les erreurs quand c'est en échec.

En général cela se fait en ajoutant une ligne dans /etc/init.d/domoticz.sh, à la suite de celles déjà présentes:

Code : Tout sélectionner

DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
Sur un PI sans RTC, une cause bien connue d'échec de démarrage automatique au reboot est liée à un watchdog interne ç domoticz qui se retrouve a péter faute d'heure système OK.

Une solution simple au problème, dans le même fichier, est d'ajouter au début du do_start():

Code : Tout sélectionner

        ntp-wait
        [ $? -ne 0 ]  && echo WARNING : NTP KO, Domoticz may not start!!! || echo INFO : NTP OK, starting Domoticz...
ntp-wait, par défaut, va faire jusqu'à 100 tentatives toutes les 6s... ça devrait laisser le temps au ntp (heure réseau) de monter!

Tester l'appel de la commande à la main, si elle n'est pas là installer le paquet ntpsec, dont cette commande fait partie.

Re: demarrage domoticz

Publié : 17 nov. 2023, 20:45
par knasson
OK pour le log c'était déjà programmé , mais je n'ai pas eu l'idée d'aller voir ce qu'il y avait dans /tmp/domoticz.text.
Donc au prochain plantage j'irai voir.
et puis je vais ajouter la ligne comme ceci? (merci de confirmer la syntaxe je ai testé la commande a la main c'est bon)
do_start()
{
ntp-wait
[ $? -ne 0 ] && echo WARNING : NTP KO, Domoticz may not start!!! || echo INFO : NTP$
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --chuid $USERNAME --start --quiet --pidfile $PIDFILE --exec $DAEMO$
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
}

Re: demarrage domoticz

Publié : 18 nov. 2023, 17:27
par knasson
Bonsoir,
j'ai retenu la suggestion d'aller visiter /tmp/domoticz.log
voila ce que j'obtiens le status est "running" mais le process ne démarre pas.

Code : Tout sélectionner

2023-11-18 17:08:04.997  Status: Domoticz V2023.1 (c)2012-2023 GizMoCuz
2023-11-18 17:08:04.997  Status: Build Hash: f9b9ac774, Date: 2023-02-14 15:06:40
2023-11-18 17:08:04.997  Status: Startup Path: /home/kan/domoticz/
2023-11-18 17:08:05.030  Sunrise: 07:41:00 SunSet: 17:08:00
2023-11-18 17:08:05.030  Day length: 09:28:00 Sun at south: 12:25:00
2023-11-18 17:08:05.030  Civil twilight start: 07:09:00 Civil twilight end: 17:40:00
2023-11-18 17:08:05.030  Nautical twilight start: 06:33:00 Nautical twilight end: 18:16:00
2023-11-18 17:08:05.030  Astronomical twilight start: 05:58:00 Astronomical twilight end: 18:51:00
2023-11-18 17:08:05.086  Status: PluginSystem: Started, Python version '3.7.3', 10 plugin definitions loaded.
2023-11-18 17:08:05.094  Active notification Subsystems: email, telegram (2/13)
2023-11-18 17:08:05.096  Status: WebServer(HTTP) startup failed on address :: with port: 8080: bind: Address already in use [system:98], trying ::
2023-11-18 17:08:05.096  Status: WebServer(HTTP) startup failed on address :: with port: 8080: bind: Address already in use [system:98], trying 0.0.0.0
2023-11-18 17:08:05.097  Error: WebServer(HTTP) startup failed on address 0.0.0.0 with port: 8080: bind: Address already in use [system:98]
2023-11-18 17:08:05.097  Error: WebServer(HTTP) check if no other application is using port: 8080
2023-11-18 17:08:05.103  Status: WebServer(SSL) startup failed on address :: with port: 443: bind: Address already in use [system:98], trying ::
2023-11-18 17:08:05.105  Status: WebServer(SSL) startup failed on address :: with port: 443: bind: Address already in use [system:98], trying 0.0.0.0
2023-11-18 17:08:05.107  Error: WebServer(SSL) startup failed on address 0.0.0.0 with port: 443: bind: Address already in use [system:98]
2023-11-18 17:08:05.107  Error: WebServer(SSL) check privileges for opening ports below 1024
2023-11-18 17:08:05.107  Error: Domoticz(pid:3089, tid:3089('domoticz')) received fatal signal 6 (Aborted)
2023-11-18 17:08:05.107  Error: siginfo address=0xc11, address=0xffffffff
2023-11-18 17:08:08.350  Error: Thread 1 (Thread 0xf6dba040 (LWP 3089)):
2023-11-18 17:08:08.350  Error: #0  __waitpid (options=0, stat_loc=0xffac6c98, pid=3094) at ../sysdeps/unix/sysv/linux/waitpid.c:30
2023-11-18 17:08:08.350  Error: #1  __waitpid (pid=3094, stat_loc=0xffac6c98, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
2023-11-18 17:08:08.350  Error: #2  0x002868cc in dumpstack_gdb(bool) ()
2023-11-18 17:08:08.350  Error: #3  0x00286e98 in signal_handler(int, siginfo_t*, void*) ()
2023-11-18 17:08:08.350  Error: #4  <signal handler called>
2023-11-18 17:08:08.350  Error: #5  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2023-11-18 17:08:08.350  Error: #6  0xf7758280 in __GI_abort () at abort.c:79
2023-11-18 17:08:08.350  Error: #7  0x009054c8 in __gnu_cxx::__verbose_terminate_handler() ()
2023-11-18 17:08:08.350  Error: #8  0x00868908 in __cxxabiv1::__terminate(void (*)()) ()
2023-11-18 17:08:08.350  Error: #9  0x0086897c in std::terminate() ()
2023-11-18 17:08:08.350  Error: #10 0x001ae970 in main ()
2023-11-18 17:08:55.342  Status: Domoticz V2023.1 (c)2012-2023 GizMoCuz
2023-11-18 17:08:55.342  Status: Build Hash: f9b9ac774, Date: 2023-02-14 15:06:40
2023-11-18 17:08:55.342  Status: Startup Path: /home/kan/domoticz/
2023-11-18 17:08:55.372  Sunrise: 07:41:00 SunSet: 17:08:00
2023-11-18 17:08:55.372  Day length: 09:28:00 Sun at south: 12:25:00
2023-11-18 17:08:55.372  Civil twilight start: 07:09:00 Civil twilight end: 17:40:00
2023-11-18 17:08:55.372  Nautical twilight start: 06:33:00 Nautical twilight end: 18:16:00
2023-11-18 17:08:55.372  Astronomical twilight start: 05:58:00 Astronomical twilight end: 18:51:00
2023-11-18 17:08:55.413  Status: PluginSystem: Started, Python version '3.7.3', 10 plugin definitions loaded.
2023-11-18 17:08:55.421  Active notification Subsystems: email, telegram (2/13)
2023-11-18 17:08:55.423  Status: WebServer(HTTP) startup failed on address :: with port: 8080: bind: Address already in use [system:98], trying ::
2023-11-18 17:08:55.423  Status: WebServer(HTTP) startup failed on address :: with port: 8080: bind: Address already in use [system:98], trying 0.0.0.0
2023-11-18 17:08:55.424  Error: WebServer(HTTP) startup failed on address 0.0.0.0 with port: 8080: bind: Address already in use [system:98]
2023-11-18 17:08:55.424  Error: WebServer(HTTP) check if no other application is using port: 8080
2023-11-18 17:08:55.431  Status: WebServer(SSL) startup failed on address :: with port: 443: bind: Address already in use [system:98], trying ::
2023-11-18 17:08:55.433  Status: WebServer(SSL) startup failed on address :: with port: 443: bind: Address already in use [system:98], trying 0.0.0.0
2023-11-18 17:08:55.434  Error: WebServer(SSL) startup failed on address 0.0.0.0 with port: 443: bind: Address already in use [system:98]
2023-11-18 17:08:55.434  Error: WebServer(SSL) check privileges for opening ports below 1024
2023-11-18 17:08:55.434  Error: Domoticz(pid:3137, tid:3137('domoticz')) received fatal signal 6 (Aborted)
2023-11-18 17:08:55.435  Error: siginfo address=0xc41, address=0xffffffff
2023-11-18 17:08:58.685  Error: Thread 1 (Thread 0xf67ee040 (LWP 3137)):
2023-11-18 17:08:58.685  Error: #0  __waitpid (options=0, stat_loc=0xffe9dd08, pid=3142) at ../sysdeps/unix/sysv/linux/waitpid.c:30[size=85][/size]
2023-11-18 17:08:58.685  Error: #1  __waitpid (pid=3142, stat_loc=0xffe9dd08, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
2023-11-18 17:08:58.685  Error: #2  0x002868cc in dumpstack_gdb(bool) ()
2023-11-18 17:08:58.685  Error: #3  0x00286e98 in signal_handler(int, siginfo_t*, void*) ()
2023-11-18 17:08:58.685  Error: #4  <signal handler called>
2023-11-18 17:08:58.685  Error: #5  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
2023-11-18 17:08:58.685  Error: #6  0xf718c280 in __GI_abort () at abort.c:79
2023-11-18 17:08:58.685  Error: #7  0x009054c8 in __gnu_cxx::__verbose_terminate_handler() ()
2023-11-18 17:08:58.685  Error: #8  0x00868908 in __cxxabiv1::__terminate(void (*)()) ()
2023-11-18 17:08:58.685  Error: #9  0x0086897c in std::terminate() ()
2023-11-18 17:08:58.685  Error: #10 0x001ae970 in main ()
est ce que c'est clair pour quelqu'un? moi je comprends pas

Re: demarrage domoticz

Publié : 18 nov. 2023, 17:36
par Keros
Tu as quoi qui tourne sur le Pi ? Il semblerait qu'il y est déjà un processus qui utilise les ports 80 et 443.

Re: demarrage domoticz (resolu)

Publié : 19 nov. 2023, 20:52
par knasson
bonsoir,
le log montre en effet que des sessions de Domoticz sont encore actives du coup il y a conflit.
Bon de toute façon, j'ai résolu mon problème de la façon suivante:
j'ai neutralise le démarrage "domoticz.sh" dans /etc/init.d j'ai basculé sur /etc/systemd/system avec un script "domoticz.service" que j'ai créé et qui ressemble a ca, mais qui n'a pas pas valeur d'exemple.
[Unit]
Description=domoticz_service
After=time-sync.target
[Service]
User=root
Group=users
ExecStart= /home/kan/domoticz/domoticz -www 8080 -sslwwww 443
WorkingDirectory=/home/kan/domoticz
AmbientCapabilities=CAP_NET_BIND_SERVICE
Restart=on-failure
RestartSec=1m
[Install]
WantedBy=multi-user.target
l'inconvénient est que ce script ne génère pas de "domoticz.pid" dans /var/run/ dont j'avais besoin pour faire fonctionner monit. Donc j'ai change de système de surveillance comme expliqué ici https://sigmdel.ca/michel/ha/rpi/guide_ ... z_watchdog
tout fonctionne apparemment autant que j'ai pu en juger.
J'espère que ces quelques réflexions aideront d'autres dans le même cas.