Init.d service does not autostart

Hi!

I installed prometheus-node-exporter-lua. It is enabled in LuCI --> System --> Startup. Link in /etc/rc.d exists. Still, the service does not automatically start. When started manually, either from LuCI or via console, it runs instantly.

Any ideas for further troubleshooting?

Thanks!

Well, looking at the init.d scripts, it starts quite early in the boot process. If the interfaces are not up at that point, it won't start.

Are you seeing the log message in your logs: "deferring start until listen interface $interface becomes ready"

#!/bin/sh /etc/rc.common
# Copyright (C) 2013-2017 OpenWrt.org

START=60
USE_PROCD=1

_log() {
	logger -p daemon.info -t prometheus-node-exporter-lua "$@"
}

start_service() {
	. /lib/functions/network.sh

	local interface ipv6 port bind

	config_load prometheus-node-exporter-lua.main
	config_get interface "main" listen_interface "loopback"
	config_get_bool ipv6 "main" listen_ipv6 0
	config_get port "main" listen_port 9100

	if [ "$interface" = "*" ]; then
		[ "$ipv6" = 1 ] && bind="::" || bind="0.0.0.0"
	else
		if [ "$ipv6" = 1 ]; then
			network_get_ipaddr6 bind "$interface"
		else
			network_get_ipaddr bind "$interface"
		fi

		network_is_up "$interface" && [ -n "$bind" ] || {
			_log "defering start until listen interface $interface becomes ready"
			return 0
		}
	fi

Thanks for your answer. Theres nothing like that in logread (logread | grep until).

I will try editing the init.d script increasing the START variable...

If you do that you'll need to disable it then re-enable it so that it recreates the correct symlink in /etc/rc.d

It doubt that is an issue. Add this line to the beginning of your script to get the output during the startup. Then see what is in that file after a reboot.

exec >>/root/log 2>&1

Thanks for your help.

START=80 does not help.

@fantom-x:
Where do I put the exec >>/root/log 2>&1? I tried before and after start_service() {.
/root/log stays empty...

Is the service enabled? Are there start/stop links to the file?

Before START. Add these lines as well to make sure the script gets invoked during boot:

exec >>/root/log 2>&1
echo "STARTED"
set -x