[Guide]My workaround for luci-nginx failing to start on boot

If you for some reason need to use luci-nginx in place of uhttpd, and come across this problem where nginx fails to start on boot. You can bump the starting order to 99 by editing /etc/init.d/nginx like so

START=99

USE_PROCD=1

This workaround however doesn't work for me after several firmware updates. If you happen to be in my shoes, you may try to delay the execution of the script manually instead.

Add the function below right before start_service() function.

procd_detection() {
    local current_user=$(id -un)
    local ppid=$(awk '{print $4}' /proc/$$/stat)
    local parent_cmdline=$(cat /proc/$ppid/cmdline | tr '\0' ' ')
    
	if echo "$parent_cmdline" | grep -q '/sbin/procd'; then
		DELAY=100
    	logger -s -t identity "Procd detected, delaying by ${DELAY} seconds"
		sleep $DELAY
	fi
}

And then add the following procd_detection expression at the very beginning of the start_service() function block like so.
image

Delaying by 100 seconds works for me, YMMV, you may adjust as required if it doesn't work for you. It could also be lesser if it works for you. As far as I'm concerned, the guaranteed workaround would be to have systemd or something else in charge of the startup scripts since its execution flow can be process dependent. From what I can tell, my openwrt machine tries to initiate nginx way before internet connection comes alive, making the host(s) unreachable, which ultimately leads to failure to start nginx service on boot up. Before resolving this problem, I had to manually start nginx service after each reboot, or else I won't be able to access luci web interface at all.

Cheers, happy new year.

I guess you have done your own research, but that diagnostics seems a bit weird to me... I do not understand why NGINX should fail if there is no internet connection.

Any errors from failed nginx start in logread?