Software > WeeWX
Problemas con los reinicios de weewx
jantoni:
Un lío, si
*+* *+* *+* *+* *+*
jmviper:
Por probarlo, he dejado la orange pi un cuarto de hora apagada y la he vuelto a poner en marcha.
Resultado de syslog:
May 12 15:30:38 localhost systemd-time-wait-sync[280]: adjtime state 0 status 2000 time Tue 2020-05-12 13:30:38.925722 UTC
May 12 15:30:38 localhost systemd-timesyncd[344]: Synchronized to time server for the first time 162.159.200.123:123 (0.debian.pool.ntp.org).
May 12 15:30:38 localhost systemd[1]: Started Wait Until Kernel Time Synchronized.
May 12 15:30:38 localhost systemd[1]: Reached target System Time Synchronized.
May 12 15:30:38 localhost systemd[1]: Starting weewx weather system...
May 12 15:30:38 localhost systemd[1]: Started Daily man-db regeneration.
May 12 15:30:38 localhost systemd[1]: Started Clean PHP session files every 30 mins.
May 12 15:30:38 localhost systemd[1]: Started Daily apt download activities.
May 12 15:30:38 localhost systemd[1]: Started Daily apt upgrade and clean activities.
May 12 15:30:38 localhost systemd[1]: Started Daily rotation of log files.
May 12 15:30:38 localhost systemd[1]: Reached target Timers.
May 12 15:30:39 localhost systemd[1]: weewx.service: Supervising process 1220 which is not our child. We'll most likely not notice when it exits.
May 12 15:30:39 localhost systemd[1]: Started weewx weather system.
Creo que las primeras líneas lo dicen todo.
Primeramente el servicio systemd-time-wait-sync retrasa el inicio de los servicios que dependen de systemd-timesyncd para su arranque (weewx uno de ellos y el que más nos importa) y cuando está todo sincronizado incluido el kernel empieza a arrancar weewx.
De esa forma arrancando con weewx.service no tendremos el problema de ese desfase de tiempo al arrancar la raspi si ha estado horas apagada.
Rubendgl:
--- Cita de: jmviper en 11 de Mayo de 2020, 19:51:00 ---Hola Rubén
Prueba a realizar el segundo paso para quitar el falso reloj:
https://github.com/weewx/weewx/wiki/Raspberry-Pi
$ sudo systemctl stop systemd-timesyncd
$ sudo systemctl disable systemd-timesyncd
Eso quitaría la sincronización de hora que usa la raspi.
También en el enlace al foro que hay en esa página se explica que ese servicio dependería de otro llamado systemd-time-wait-sync que esperaría a que se hubiese sincronizado la hora con el servidor NTP
Qué te pone al ejecutar sudo systemctl status systemd-time-wait-sync ??
--- Fin de la cita ---
Bien, pues este es el resultado:
--- Código: ---pi@raspberrypi:~ $ sudo systemctl stop systemd-timesyncd
Warning: The unit file, source configuration file or drop-ins of systemd-timesyn
cd.service changed on disk. Run 'systemctl daemon-reload' to reload units.
pi@raspberrypi:~ $ sudo systemctl disable systemd-timesyncd
Removed /etc/systemd/system/dbus-org.freedesktop.timesync1.service.
Removed /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service.
pi@raspberrypi:~ $ sudo systemctl status systemd-time-wait-sync
● systemd-time-wait-sync.service - Wait Until Kernel Time Synchronized
Loaded: loaded (/lib/systemd/system/systemd-time-wait-sync.service; disabled; vendor preset: enab
Active: inactive (dead)
Docs: man:systemd-time-wait-sync.service(8)
--- Fin del código ---
Rubendgl:
Bueno, pues lo siguiente que he probado ha sido.
pi@raspberrypi:~ $ sudo systemctl start systemd-time-wait-sync
pi@raspberrypi:~ $ sudo systemctl status systemd-time-wait-sync
● systemd-time-wait-sync.service - Wait Until Kernel Time Synchronized
Loaded: loaded (/lib/systemd/system/systemd-time-wait-sync.service; disabled; vendor preset: enab
Active: active (exited) since Tue 2020-05-12 18:59:26 UTC; 8s ago
Docs: man:systemd-time-wait-sync.service(8)
Process: 17839 ExecStart=/lib/systemd/systemd-time-wait-sync (code=exited, status=0/SUCCESS)
Main PID: 17839 (code=exited, status=0/SUCCESS)
may 12 18:59:26 raspberrypi systemd[1]: Starting Wait Until Kernel Time Synchronized...
may 12 18:59:26 raspberrypi systemd-time-wait-sync[17839]: adjtime state 0 status 2001 time Tue 2020
may 12 18:59:26 raspberrypi systemd[1]: Started Wait Until Kernel Time Synchronized.
pi@raspberrypi:~ $ date
mar may 12 18:59:42 UTC 2020
Ahora si sale como activo ese servicio, no se. Seguramente la haya liado gorda y ni me atrevo a reiniciar para probar.
jmviper:
Parece que está deshabilitado... Loaded: loaded (/lib/systemd/system/systemd-time-wait-sync.service; disabled; vendor preset: enab
Si ejecutas sudo systemctl list-unit-files | grep systemd-time-wait-sync.service te debe de salir como disabled
Para activarlo sudo systemctl enable systemd-time-wait-sync.service
Ya he dicho que todo esto es para que funcione con el sincronizador de tiempo de systemd y que no inicie weewx hasta que el sistema no esté en hora.
Los pasos ya los he puesto en mis anteriores mensajes.
Crear el archivo /etc/systemd/system/weewx.service y poner en su interior (copiar y pegar) este código:
--- Código: ---# systemd configuration for weewx
[Unit]
Description=weewx weather system
Requires=time-sync.target
After=time-sync.target
# Uncomment the following two line if your database is written using mysql or MariaDB on the same host
#After=mysql.service
#BindsTo=mysql.service
# The following two lines should be uncommented and used if you
# have enabled Restart=on-failure in the [Service] section below.
# StartLimitIntervalSec=100
# StartLimitBurst=5
[Service]
# The following two lines may be uncommented and used if you
# want the weewx service to automatically restart if it crashes.
# This can be particularly useful if weewx has an IP connection to the weather station
# it is monitoring, since transient network problems are quite
# common, and may cause the daemon to crash.
# Adjust timing according to the typical recovery times in your situation
#Restart=on-failure
#RestartSec=20
# See notes later in this wiki; by default weewx will run with root privileges, so
# comment out the following two lines to run weewx as root.
# User=weewx
# Group=weewx
# create a runtime directory below /run, because non-root users cannot create a file in /run itself
# This works for root as well as non-root users.
RuntimeDirectory=weewx
PIDFile=/run/weewx/weewx.pid
# setting the preserve option stops systemd deleting the PID file when weewx exits (debugging only)
# RuntimeDirectoryPreserve=yes
ExecStart=/usr/bin/weewxd --daemon --pidfile=/run/weewx/weewx.pid /etc/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID
Type=forking
[Install]
WantedBy=multi-user.target
--- Fin del código ---
reiniciamos la carga de servicios con sudo systemctl daemon-reload
reiniciamos weewx y ya deberá salirnos que está cargado con weewx.service:
root@orangepipc:~# sudo service weewx status
● weewx.service - weewx weather system
Loaded: loaded (/lib/systemd/system/weewx.service; enabled; vendor preset: enabled)
si es así ya podemos quitar de que se cargue con el viejo script /etc/init.d/weewx ejecutando sudo update-rc.d weewx remove
solo falta quitar ntp (sudo apt purge ntp) y configurar /etc/systemd/timesyncd.conf así:
--- Código: ---# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.
[Time]
NTP=0.debian.pool.ntp.org
FallbackNTP=1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
--- Fin del código ---
Con esas líneas ya sincronizará la hora con los servidores NTP de debian al iniciar la raspi.
Reiniciar la raspi a ver cómo ha ido la cosa.... estado de weewx, si está funcionando es un buen síntoma *-* *-* y ver el estado de los servicios de sincronización de systemd
sudo systemctl status systemd-time-wait-sync
sudo systemctl status systemd-timesyncd
Navegación
[#] Página Siguiente
[*] Página Anterior
Ir a la versión completa