Shutdown, reboot procd script timeout

Hello,

I really researched a lot before opening this topic, but unfortunately I couldn't find how to change the maximum time that openwrt waits before restarting.

I did a lot of testing and it waits a maximum of 30 seconds and kills any active process. I looked in the topics and documentation and nowhere did I find anything about the reboot time.

Is there a way to increase this maximum time of 30 seconds that it waits? I need at least 60 seconds to finish my process correctly.

What I want is to increase the maximum time it waits before restarting so I can safely finish everything.

/etc/init.d/test works fine with start/stop. But at shutdown, openwrt doesn't wait for it to complete, after 30 seconds it kills and restarts.

Example: https://openwrt.org/docs/guide-developer/procd-init-script-example

/var/myscript.sh

#!/bin/sh
 
#these if statements will check input and place default values if no input is given
#they will also check if input is a number so you can call 
#this script with just a time and it will still work correctly
 
if [ "$1" = '' ]; then
    name="You"
else
    if echo "$1" | egrep -q '^[0-9]+$'; then
        name="You"
    else
        name="$1"
    fi
fi
 
if [ "$2" = '' ]; then
    every="5"
else
    every="$2"
fi
 
if echo "$1" | egrep -q '^[0-9]+$'; then
    every="$1"
fi
 
#endless loop, will print the message every X seconds as indicated in the $every variable
 
while [ 1 ]; do 
    echo "Hey, $name, it's time to get up"
    sleep $every
done
 
exit 0

/etc/init.d/test

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01

start_service() {
    procd_open_instance
    procd_set_param command /bin/sh "/var/myscript.sh"
	procd_set_param term_timeout 120
    procd_close_instance
}

stop_service() {
	sleep 60
}

service_stopped() {
	echo 'stopped'
}

The documentation mentions procd_set_param term_timeout 120 which actually waits for my script to finish before killing the process, but the reboot does not respect it. Does anyone know in which file or where I change the maximum reboot/shutdown time?

I've already used shutdown() in init.d, but it also has no effect, since I understand that if you already have stop(), openwrt automatically does shutdown()

With shutdown() /etc/init.d/test

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=95
STOP=01

start_service() {
    procd_open_instance
    procd_set_param command /bin/sh "/var/myscript.sh"
	procd_set_param term_timeout 120
    procd_close_instance
}

stop_service() {
	sleep 60
}

service_stopped() {
	echo 'stopped'
}

shutdown(){
   stop
}

I would like to not have to manually call /etc/init.d/service stop every time I want to restart.

I know that I will rarely restart, however, I would like to know if there is any way to change this default behavior.

Of course my real script is different, I want to correctly shut down a qemu-system-x86_64 VM. Which works perfectly with start/stop, but shutdown doesn't respect time.

I would appreciate it if anyone has any ideas to help me.

Machine:
OpenWrt 23.05.3
N5100 - x86/64

It’s been a while since I looked at procd so not sure if procd_set_param respawn is worth a look.