Mycodo Daemon stuck in activating (start-pre)

Hey @KyleGabriel,

This will be my 3rd time reinstalling mycodo from scratch again and I can’t figure out why the same keeps happening but this is the current state of things:

service mycodo status
● mycodo.service - Mycodo server
Loaded: loaded (/home/gg/Mycodo/install/mycodo.service; enabled; vendor preset: enabled)
Active: activating (start-pre) since Sun 2022-07-24 14:35:02 SAST; 11min ago
Cntrl PID: 1235 (bash)
Tasks: 2 (limit: 415)
CPU: 17.464s
CGroup: /system.slice/mycodo.service
└─1235 /bin/bash /var/mycodo-root/install/influxdb_wait_until_running.sh

Jul 24 14:35:02 hector systemd[1]: Starting Mycodo server…

gg@hector:/var/log/mycodo $ service influxd status
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
Active: activating (start) since Sun 2022-07-24 15:00:42 SAST; 45s ago
Docs: InfluxDB OSS 2.3 Documentation
Cntrl PID: 17137 (influxd-systemd)
Tasks: 9 (limit: 415)
CPU: 35.493s
CGroup: /system.slice/influxdb.service
├─17137 /bin/bash -e /usr/lib/influxdb/scripts/influxd-systemd-start.sh
├─17138 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
└─17588 sleep 1

Jul 24 15:01:16 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 25 attempts…
Jul 24 15:01:18 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 26 attempts…
Jul 24 15:01:19 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 27 attempts…
Jul 24 15:01:21 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 28 attempts…
Jul 24 15:01:22 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 29 attempts…
Jul 24 15:01:23 hector influxd-systemd-start.sh[17138]: ts=2022-07-24T13:01:23.327483Z lvl=info msg=“Reading file” log_id=0bt4_J20000 engine=tsm1 service=cacheloader path=/var/lib/influxdb/wal/_internal/monitor/5/_00002.wal size=10487189
Jul 24 15:01:24 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 30 attempts…
Jul 24 15:01:25 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 31 attempts…
Jul 24 15:01:26 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 32 attempts…
Jul 24 15:01:27 hector influxd-systemd-start.sh[17137]: InfluxDB API unavailable after 33 attempts…

ps aux | grep mycodo
root 335 0.6 1.7 25220 7656 ? Ss 14:33 0:05 /var/mycodo-root/env/bin/python -m gunicorn --workers 1 --worker-class gthread --threads 2 --timeout 300 --pid /var/run/mycodoflask.pid --bind unix:/usr/local/mycodoflask.sock start_flask_ui:app
root 613 7.9 12.2 88352 53868 ? Sl 14:33 1:08 /var/mycodo-root/env/bin/python -m gunicorn --workers 1 --worker-class gthread --threads 2 --timeout 300 --pid /var/run/mycodoflask.pid --bind unix:/usr/local/mycodoflask.sock start_flask_ui:app
root 1235 0.2 0.6 7884 2808 ? Ss 14:35 0:02 /bin/bash /var/mycodo-root/install/influxdb_wait_until_running.sh
gg 9394 1.0 0.4 7436 1980 pts/0 S+ 14:48 0:00 grep --color=auto mycodo

Currently I have the following setup, 1x Temp & Humidity sensor, 1x Co2 Sensor, 1x 20x4 LCD display, 1x 3 port Kasa Smart plug & 1x 6 Port Kasa smart plug.
Whenever I add a function to control humidity, exactly according to documentation, and I restart mycodo I have this issue. Could be something else but this is what I’ve noticed so far when setting it up from scratch again.

What I’ve tried:

  1. Rebooting.
  2. Restarting the mycodo daemon with sudo service mycodo restart
  3. Killing the mycodo, influxd.
  4. Recovering from a working backup. When I recovered from a working backup it got to the point where it restarts the mycodo daemon, but then the daemon never starts up again and the recovery process sits and waits until it starts. If I manually kill the daemon it carries on with the recovery and says recovery successful. Daemon never starts and I’m unable to start it manually. Shows same message as above, “Active: activating (start-pre)”
  5. Creating an empty influxd db.
  6. Waiting hours for the influxd and mycodo daemon to start
  7. Reinstalling mycodo from scratch. This works until I get to the above point with my config and then restart.

What I have:

Raspberry Pi Zero W
64gb Sandisk Extreme Micro SD Card
3 Port Kasa
6 Port Kasa
MH-Z19B C02 sensor
AM2315C - Encased I2C Temperature/Humidity Sensor
HiLetgo 2004 20X4 LCD Display
TerraBloom ECMF-100

Will you let me know what logs I can supply to help? I’ve attached mycodo, sys and daemon logs.
Mycodo logs.zip (3.8 MB)

Cheers

What operating system?

Raspberry Pi OS Lite 32bit, 11 bullseye, Kernal Linux version 5.15.32+

Are you performing sudo apt update && sudo apt upgrade before installing?

Yes, performing sudo apt update & sudo apt upgrade before installing

Hi,

I had the same problem. It’s apprently the Raspberry Zero which is no fast enough to start the influxDB service at boot.

The solution is to augment the sleep time :
sudo nano /usr/lib/influxdb/scripts/influxd-systemd-start.sh

Line 30 change sleep 1 in sleep 3 or more

1 Like

ok cool will give it a shot, thanks!

still seem to happen even after appending the mentioned line in /usr/lib/influxdb/scripts/influxd-systemd-start.sh

Jul 30 12:01:40 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 21 attempts…
Jul 30 12:01:43 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 22 attempts…
Jul 30 12:01:46 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 23 attempts…
Jul 30 12:01:50 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 24 attempts…
Jul 30 12:01:53 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 25 attempts…
Jul 30 12:01:56 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 26 attempts…
Jul 30 12:02:00 hector influxd-systemd-start.sh[1865]: InfluxDB API unavailable after 27 attempts…
Jul 30 12:02:02 hector systemd[1]: influxdb.service: start operation timed out. Terminating.
Jul 30 12:02:02 hector systemd[1]: influxdb.service: Failed with result ‘timeout’.
Jul 30 12:02:02 hector systemd[1]: Failed to start InfluxDB is an open-source, distributed, time series database.
Jul 30 12:02:02 hector systemd[1]: influxdb.service: Consumed 1min 22.626s CPU time.
Jul 30 12:02:03 hector systemd[1]: influxdb.service: Scheduled restart job, restart counter is at 4.
Jul 30 12:02:03 hector systemd[1]: Stopped InfluxDB is an open-source, distributed, time series database.
Jul 30 12:02:03 hector systemd[1]: influxdb.service: Consumed 1min 22.626s CPU time.
Jul 30 12:02:03 hector systemd[1]: Starting InfluxDB is an open-source, distributed, time series database…
Jul 30 12:02:03 hector influxd-systemd-start.sh[2277]: Merging with configuration at: /etc/influxdb/influxdb.conf
Jul 30 12:02:03 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:03.841405Z lvl=info msg=“InfluxDB starting” log_id=0b~djhlG000 version=1.8.10 branch=1.8 commit=688e697c51fd
Jul 30 12:02:03 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:03.847286Z lvl=info msg=“Go runtime” log_id=0b~djhlG000 version=go1.13.8 maxprocs=1
Jul 30 12:02:03 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:03.953476Z lvl=info msg=“Using data dir” log_id=0b~djhlG000 service=store path=/var/lib/influxdb/data
Jul 30 12:02:03 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:03.959813Z lvl=info msg=“Compaction settings” log_id=0b~djhlG000 service=store max_concurrent_compactions=1 throughput_bytes_per_second=50331648 throughput_bytes_per_second_burst=50331648
Jul 30 12:02:03 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:03.965233Z lvl=info msg=“Open store (start)” log_id=0b~djhlG000 service=store trace_id=0b~djiFG000 op_name=tsdb_open op_event=start
Jul 30 12:02:04 hector influxd-systemd-start.sh[2275]: ts=2022-07-30T10:02:04.063415Z lvl=info msg=“Reading file” log_id=0b~djhlG000 engine=tsm1 service=cacheloader path=/var/lib/influxdb/wal/_internal/monitor/7/_00001.wal size=10487762
Jul 30 12:02:04 hector influxd-systemd-start.sh[2291]: Merging with configuration at: /etc/influxdb/influxdb.conf
Jul 30 12:02:04 hector influxd-systemd-start.sh[2272]: InfluxDB API unavailable after 1 attempts…
Jul 30 12:02:08 hector influxd-systemd-start.sh[2272]: InfluxDB API unavailable after 2 attempts…

Ok in my case i had to reinstall completly Mycodo and i purged all influxDB packages before to reinstall mycodo.
Directly after i changed the time sleep.
The problem reappears if I do a sudo update && upgrade at startup while influxDB is starting too.
I had my two RPI zero which had that problem.
Hope it will be the same for you

Ok going to try this now, correct me if I’m wrong, I’ve got a freshly formatted sd card, going to install Raspberry Pi OS Lite 32bit again, then install Mycodo but without running sudo update && upgrade at startup? Then after it has been installed I edit /usr/lib/influxdb/scripts/influxd-systemd-start.sh?

Also did you have the issue where Mycodo daemon started but the InfluxDB could not and gave the above errors?