Procd init script duplicates itself when restarted

Hello. I want my script to start with system startup and restart in case it breaks. I'm using the official openwrt documentation and have no idea why the script restarts when I use /etc/init.d/myscript stop and not only restarts, but creates two instances of my script.
Without procd_set_param respawn it works as expected. I understand that on stop or restart this restart parameter recognises that the script has broken down and restarts it, but I don't know how to fix it. Do you have any idea? Thanks in advance

#!/bin/sh /etc/rc.common



start_service() {
        procd_set_param pidfile $PIDFILE
        procd_set_param stdout 1
        procd_set_param stderr 1
        procd_set_param command sh "$SCRIPT"
        procd_set_param respawn 

stop_service() {
        kill $(cat $PIDFILE)

stop_service() is called after procd already killed the service, usually stop_service() is only needed when you need additional things to do after your service has been killed by procd. The service itself should run in the foreground. The procd command should directly call your script, remove the needless "sh". For working procd examples scan the OpenWrt package repo (

1 Like

Thanks for the response.
After stopping the service (without stop_service() function) there is no service process running anymore, but still works, it is not killed or restarted. That's why I userd kill $(cat $PIDFILE) previously.
Do you know why this happens?

Please start your service and provide the output of:

ubus call service list '{"name":"xxxSERVICENAMExxx"}'

	"myservice": {
		"instances": {
			"instance1": {
				"running": true,
				"pid": 1146,
				"command": [
				"term_timeout": 5,
				"respawn": {
					"threshold": 3600,
					"timeout": 5,
					"retry": 5

Does what you're running do it's own daemonization? That tends to confuse procd. If you can run it foreground that would help you a great deal.

Hello. In the file there is a python script running. If I call /etc/init.d/myscript stop, the stops, but a python script is still running. If I add killing python scipt to stop_service(), it is being respawned.