Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#2103 - procd: respawn parameters lost when using /etc/init.d/<program>/restart #7128

Closed
openwrt-bot opened this issue Feb 6, 2019 · 0 comments
Labels

Comments

@openwrt-bot
Copy link

antismap:

procd loses respawn parameters when using /etc/init.d//restart
This happens when the program takes too long time to stop.

Here is the reason why:

  1. in instance.c, the respawn and restart bools are set to false.
//instance.c void instance_stop(struct service_instance *in, bool halt) { ... in->restart = in->respawn = false; => restart and respawn bool set to false kill(in->proc.pid, SIGTERM); ... }
  1. in service_handle_set (called for starting the process anew), we have the following code:

s = avl_find_element(&services, name, s, avl);
if (s) {
DEBUG(2, "Update service %s\n", name);
return service_update(s, tb, add); => we are here, because the program didn't yet terminate ! avl_find_element doesn't return NULL
}

DEBUG(2, "Create service %s\n", name);
s = service_alloc(name);
if (!s)
	return UBUS_STATUS_UNKNOWN_ERROR;

ret = service_update(s, tb, add);</code>

In my case, avl_find_element returns the previous instance because the program didn't close yet. service_update is called on the previous structure, without allocating a new one.

problem: in->restart and in->respawn are still false !
consequence: "respawn" parameters are lost. This is visible in the output of
ubus call service list '{"name":"program"}'
example:
before /etc/init.d/program/restart :
"program": {
"instances": {
"program": {
"running": true,
"pid": 4904,
"command": [
"/usr/bin/program",
],
"term_timeout": 5,
"limits": {
"core": "unlimited"
},
"respawn": {
"threshold": 3600,
"timeout": 1,
"retry": 0
},
"pidfile": "/var/run/program.pid"
}
}
},

after
"program": {
"instances": {
"program": {
"running": true,
"pid": 4904,
"command": [
"/usr/bin/program",
],
"term_timeout": 5,
"limits": {
"core": "unlimited"
},
"pidfile": "/var/run/program.pid"
}
}
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant