demarrage domoticz à la mise sous tension

Photographie ultra-rapide, pilotage d'imprimante 3D ou de CNC, fabrication de bière.... Enfin tout ce que le Raspberry peut gérer trouvera sa place dans cette rubrique

Modérateur : Francois

piper
Raspinaute
Messages : 641
Enregistré le : sam. 5 juin 2021 18:57

Re: demarrage domoticz à la mise sous tension

Message par piper » mar. 9 août 2022 18:46

Ce que j'ai expliqué
1) créer un script pour systemd qui précise ce qu'est le service et quel script lancé au démarrage
2) activer le service (systemctl enable nomchoisis)
3) au reboot, le service doit alors être lancé
Il est possible de le lancer manuellement sans rebooter (systemctl start nomduservide), de connaitre son statut (status), de l'arrêter (stop), de supprimer le démarrage automatique (disable) et de connaitre le détail des actions du service (journalctl)
3 Pi4 : Emby / Samba , Librelec, Android TV
3 Pi3 : Hifiberry /OSMC, Games station, Samba / VPN / HotSpot Wifi
2 Pi2 : RFID, radio reveil (PiReveil)
1 Pi0 : traker GPS et acquisitions
1 Pi0 2W : tests divers
5 Arduinos dont 4 nanos et 1 Mega
1 ESP32

dou_dou_69
Messages : 53
Enregistré le : sam. 23 juil. 2022 11:36

Re: demarrage domoticz à la mise sous tension

Message par dou_dou_69 » jeu. 18 août 2022 17:52

Bonjour,

Merci de ton aide mais mes connaissances sont limitées et rien que le 1) me bloque.

Comment créer ce script pour pouvoir ensuite l'activé au démarrage?

piper
Raspinaute
Messages : 641
Enregistré le : sam. 5 juin 2021 18:57

Re: demarrage domoticz à la mise sous tension

Message par piper » ven. 19 août 2022 21:09

Bon je réexplique :
Tu sais quoi lancer pour démarrer manuellement docmoticz donc
Dans un terminal (l'éicône en forme de carré noir si tu as le bureau de lancer sinon, avec putty à distance)

Code : Tout sélectionner

sudo nano /lib/systemd/system/domoticz.service
La dedans tu mets

Code : Tout sélectionner

[Unit]
Description=domoticz
After=rc-local.service  #par exemple

[Service]
Type=simple
User=root #ou un autre user qui a les droits de lancement
ExecStart=commande à lancer pour démarrer domoticz <<=== à toi de mettre ce qu'il faut !
#ExecStop=commande à lancer pour l'arrêter (optionnel)
PIDFile=/var/run/domoticz.pid #ou autre, à toi de choisir)

[Install]
WantedBy=multi-user.target
pour enregistrer les modifs dans nano : CTRL+O, pour quitter : CTRL+X

Ensuite, tu fais prendre en compte les modifications

Code : Tout sélectionner

sudo systemctl daemon-reload
Après, tu actives le service

Code : Tout sélectionner

sudo systemctl enable domoticz.service
(domoticz.service correspond au nom du fichier /lib/systemd/system/domoticz.service créé précédemment)

Tu essais son démarrage manuellement

Code : Tout sélectionner

sudo systemctl start domoticz.service
Tu vérifies qu'il est bien démarré :

Code : Tout sélectionner

sudo systemctl status domoticz.service
Tu vois un problème ? alors résous-le
Tout est OK ?
Alors

Code : Tout sélectionner

sudo reboot
Et domocticz doit être démarré

Si là tu ne comprends pas mieux, je ne peux rien faire de plus à part prendre la main sur ton rasbperry et le faire moi-même
3 Pi4 : Emby / Samba , Librelec, Android TV
3 Pi3 : Hifiberry /OSMC, Games station, Samba / VPN / HotSpot Wifi
2 Pi2 : RFID, radio reveil (PiReveil)
1 Pi0 : traker GPS et acquisitions
1 Pi0 2W : tests divers
5 Arduinos dont 4 nanos et 1 Mega
1 ESP32

dou_dou_69
Messages : 53
Enregistré le : sam. 23 juil. 2022 11:36

Re: demarrage domoticz à la mise sous tension

Message par dou_dou_69 » dim. 21 août 2022 19:43

bonjour,
merci d'avoir détaillé

quand je tape cette commande :
sudo systemctl enable domoticz.service

il me renvoi :
Failed to enable unit: Unit /run/systemd/generator.late/domoticz.service is transient or generated.

est-ce du au fait que j'ai déjà surement essayé de créé ce fichier avec surement le mauvais contenu et donc probablement l'ai je déjà activé?

après débranchement et rebranchement quand je tape la commande :
sudo systemctl enable domoticz.service

il me retourne :
domoticz.service - LSB: Home Automation System
Loaded: loaded (/etc/init.d/domoticz.sh; generated; vendor preset: enabled)
Active: active (running) since Thu 2016-11-03 17:16:47 UTC; 28s ago
Docs: man:systemd-sysv-generator(8)
Process: 727 ExecStart=/etc/init.d/domoticz.sh start (code=exited, status=0/SU
Tasks: 20 (limit: 4915)
CGroup: /system.slice/domoticz.service
└─1115 /home/linaro/domoticz/domoticz -daemon -www 8080 -sslwww 443

Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.859 Status: D
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.859 Status: B
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.860 Status: S
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: domoticz: Domoticz is starting up.
Nov 03 17:16:47 linaro-alip domoticz[1096]: Domoticz is starting up....
Nov 03 17:16:47 linaro-alip domoticz[1115]: Domoticz running...
Aug 21 17:38:21 linaro-alip domoticz[1115]: Domoticz stopped...

ça se lance mais se coupe à mise à l'heure et date.

Voici les commandes qui fonctionnaient mais ne fonctionnent plus
sudo service domoticz.sh start
sudo systemctl start domoticz.service
sudo /etc/init.d/domoticz.sh start

obligé de taper: ./domoticz dans le répertoire domoticz pour le lancé et du coup ça me bloque une console putty ouverte car domoticz s’arrête à la fermeture de la console

piper
Raspinaute
Messages : 641
Enregistré le : sam. 5 juin 2021 18:57

Re: demarrage domoticz à la mise sous tension

Message par piper » dim. 21 août 2022 20:11

Pour le 1er warning, moi, je n'utiliserai pas dans systemd un script du dossier réservé à SYSV (/etc/init.d)
Mais ce n'est qu'un warning


Pour "l'arrêt brutal" : comment savez-vous que le service s'est arrêté ?
Une fois "arrêter", que dit sudo systemctl status domoticz.service ?
voir mieux:
sudo journalctl -u domoticz.service

et domoticz ne renseigne pas de fichier de log ? (je ne connais pas domoticz)
3 Pi4 : Emby / Samba , Librelec, Android TV
3 Pi3 : Hifiberry /OSMC, Games station, Samba / VPN / HotSpot Wifi
2 Pi2 : RFID, radio reveil (PiReveil)
1 Pi0 : traker GPS et acquisitions
1 Pi0 2W : tests divers
5 Arduinos dont 4 nanos et 1 Mega
1 ESP32

dou_dou_69
Messages : 53
Enregistré le : sam. 23 juil. 2022 11:36

Re: demarrage domoticz à la mise sous tension

Message par dou_dou_69 » lun. 22 août 2022 08:54

1er warning
vous devez parler de
Failed to enable unit: Unit /run/systemd/generator.late/domoticz.service is transient or generated.
que feriez-vous?

je sais que le service s'est arrété car quand je tape
sudo systemctl status domoticz.service (désolé pour la faute de frappe dans le message précédent)
ile me renvoi
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.859 Status: D
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.859 Status: B
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: 2016-11-03 17:16:47.860 Status: S
Nov 03 17:16:47 linaro-alip domoticz.sh[727]: domoticz: Domoticz is starting up.
Nov 03 17:16:47 linaro-alip domoticz[1096]: Domoticz is starting up....
Nov 03 17:16:47 linaro-alip domoticz[1115]: Domoticz running...
Aug 21 17:38:21 linaro-alip domoticz[1115]: Domoticz stopped...

et c'est confirme par l'accès impossible via l'explorateur internet

la commande
sudo journalctl -u domoticz.service
me retourne

-- Logs begin at Thu 2016-11-03 17:16:42 UTC, end at Mon 2022-08-22 06:50:52 UTC
Nov 03 17:16:46 linaro-alip domoticz.sh[746]: 2016-11-03 17:16:46.504 Status: D
Nov 03 17:16:46 linaro-alip domoticz.sh[746]: 2016-11-03 17:16:46.505 Status: B
Nov 03 17:16:46 linaro-alip domoticz.sh[746]: 2016-11-03 17:16:46.505 Status: S
Nov 03 17:16:46 linaro-alip domoticz.sh[746]: domoticz: Domoticz is starting up.
Nov 03 17:16:46 linaro-alip domoticz[901]: Domoticz is starting up....
Nov 03 17:16:46 linaro-alip domoticz[940]: Domoticz running...
Aug 22 06:47:29 linaro-alip domoticz[940]: Domoticz stopped...

toujours ce "stopped" après la mise à l'heure

piper
Raspinaute
Messages : 641
Enregistré le : sam. 5 juin 2021 18:57

Re: demarrage domoticz à la mise sous tension

Message par piper » lun. 22 août 2022 22:22

OK pigé :
Le pi n'est pas du tout à l'heure au boot (donc il a été débranché)
Au boot, il lance domiticz (avec une heure fausse)
puis, dans le processus de boot, il lance sa recherche d'heure actuelle via un serveur de temps
Il le trouve, met son heure à jour et ça fait arrêter domoticz

Je pensais que le pb venait suite à une mise à l'heure manuelle

Ce problème est largement documenté sur internet, il semble que de très nombreux internautes ont ce soucis
Une des solutions serait de forcer le service à ne démarrer qu'une fois le service de mise à l'heure lancé

En mettant dans le fichier service :
After=network.target time-sync.target

il faudra faire un sudo systemctl daemon reload pour que le changement dans le fichier service soit pris en compte par systemd avant d'essayer.

Pour le warning, il semble (pas sûr) que ça vient du fait que le script sh de chargement est dans /etc/init.d/ dossier réserver à SYSV ("ancêtre" de systemd)
La plupart des distributions Linux ont totalement abandonné SYSV (Fedora, CentOS, RedHat), mais pas les Debian qui sont toujours à la traîne.
Actuellement sur Debian, (comme RaspiOS), on en est à une situation de transition où SYSV et Systemd cohabitent parce que tout le système n'a pas encore migré sur systemd.

Une option pour le vérifier :
Copier le script sh de démarrage ailleurs. Mettre le fichier service à jour pour qu'il connaisse le nouvel emplacement de celui-ci, sudo systemctl daemon reload
et essayer voir si le warning a disparu

Mais c'est une théorie dont je ne suis pas sûr.
3 Pi4 : Emby / Samba , Librelec, Android TV
3 Pi3 : Hifiberry /OSMC, Games station, Samba / VPN / HotSpot Wifi
2 Pi2 : RFID, radio reveil (PiReveil)
1 Pi0 : traker GPS et acquisitions
1 Pi0 2W : tests divers
5 Arduinos dont 4 nanos et 1 Mega
1 ESP32

dou_dou_69
Messages : 53
Enregistré le : sam. 23 juil. 2022 11:36

Re: demarrage domoticz à la mise sous tension

Message par dou_dou_69 » mar. 23 août 2022 00:03

maintenant la commande
sudo systemctl enable domoticz.service
me renvoi
Failed to enable unit: File domoticz.service: Invalid argument

et les commandes
sudo systemctl status domoticz.service
● domoticz.service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)

Nov 03 17:18:52 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Nov 03 17:18:52 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Nov 03 17:18:52 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Nov 03 17:18:52 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 03 17:19:22 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:1] Assignment outside of section. Ignoring.
Nov 03 17:19:22 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:2] Assignment outside of section. Ignoring.
Nov 03 17:19:22 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Nov 03 17:19:22 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Nov 03 17:19:22 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Nov 03 17:19:22 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

sudo /etc/init.d/domoticz.sh status
● domoticz.service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)

Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:2] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Nov 03 17:19:36 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:1] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:2] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start

sudo service domoticz.sh status
● domoticz.service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)

Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Nov 03 17:19:36 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Nov 03 17:19:36 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 22 21:58:12 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:1] Assignment outside of section. Ignoring.
Aug 22 21:58:12 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:2] Assignment outside of section. Ignoring.
Aug 22 21:58:12 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:3] Assignment outside of section. Ignoring.
Aug 22 21:58:12 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:4] Assignment outside of section. Ignoring.
Aug 22 21:58:12 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Aug 22 21:58:12 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

il essaye toujours de lancer domoticz avant la mise a l'heure
malgré l'ajout de la ligne
[Unit]
Description=domoticz
After=rc-local.service #par exemple
After=network.target time-sync.target

vu que les commandes habituelles pour lancer domoticz ne fonctionne plus
malgré la mise à l'heure je penses que ce retour execstart and execstop refusing sont normal

piper
Raspinaute
Messages : 641
Enregistré le : sam. 5 juin 2021 18:57

Re: demarrage domoticz à la mise sous tension

Message par piper » mar. 23 août 2022 11:04

C'est normal :
Tu as mis
After=rc-local.service #par exemple
After=network.target time-sync.target

Ca fait 2 sections After
Il ne peut y en avoir qu'une
Mets la 1ère en commentaire en mettant un # devant

#After=rc-local.service
After=network.target time-sync.target
3 Pi4 : Emby / Samba , Librelec, Android TV
3 Pi3 : Hifiberry /OSMC, Games station, Samba / VPN / HotSpot Wifi
2 Pi2 : RFID, radio reveil (PiReveil)
1 Pi0 : traker GPS et acquisitions
1 Pi0 2W : tests divers
5 Arduinos dont 4 nanos et 1 Mega
1 ESP32

dou_dou_69
Messages : 53
Enregistré le : sam. 23 juil. 2022 11:36

Re: demarrage domoticz à la mise sous tension

Message par dou_dou_69 » mar. 23 août 2022 19:09

trés bien merci

voici le retour de

sudo systemctl status domoticz.service

Aug 23 17:06:24 linaro-alip systemd[1]: [/lib/systemd/system/domoticz.service:9] Executable path is not absolute, ignoring: sudo /etc/init.d/domoticz.sh start
Aug 23 17:06:24 linaro-alip systemd[1]: domoticz.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

avec le fichier domoticz.service

Unit]
Description=domoticz
#After=rc-local.service
After=network.target time-sync.target

[Service]
Type=simple
User=linaro
ExecStart=sudo /etc/init.d/domoticz.sh start
#ExecStop=sudo /etc/init.d/domoticz.sh stop
PIDFile=/var/run/domoticz.pid

[Install]
WantedBy=multi-user.target

lancement manuel du service
sudo /etc/init.d/domoticz.sh start
[....] Starting domoticz.sh (via systemctl): domoticz.serviceFailed to start domoticz.service: Unit domoticz.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status domoticz.service' for details.
failed!

sudo systemctl start domoticz.service
Failed to start domoticz.service: Unit domoticz.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status domoticz.service' for details.

sudo service domoticz.sh start
Failed to start domoticz.service: Unit domoticz.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status domoticz.service' for details.

maintenant il ne me reste plus qu'à trouver pourquoi les commande de lancement manuelle habituelle ne fonctionne plus c'est ca?

Répondre

Retourner vers « Les applications spécialisées du Raspberry Pi »