mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hook: fix restart hook
This commit is contained in:
parent
839c332813
commit
63e34e62f8
1 changed files with 10 additions and 4 deletions
|
@ -44,18 +44,24 @@ static int api_restart(struct api_action *h, json_t *args, json_t **resp, struct
|
|||
int ret;
|
||||
json_error_t err;
|
||||
|
||||
/* If no config is provided via request, we will use the previous one */
|
||||
if (s->api->super_node->uri)
|
||||
config = strdup(s->api->super_node->uri);
|
||||
char *cfg = NULL;
|
||||
|
||||
if (args) {
|
||||
ret = json_unpack_ex(args, &err, 0, "{ s?: s }", "config", &config);
|
||||
ret = json_unpack_ex(args, &err, 0, "{ s?: s }", "config", &cfg);
|
||||
if (ret < 0) {
|
||||
*resp = json_string("failed to parse request");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no config is provided via request, we will use the previous one */
|
||||
if (!cfg)
|
||||
cfg = s->api->super_node->uri;
|
||||
|
||||
config = strdup(cfg);
|
||||
|
||||
info("restarting to %s", config);
|
||||
|
||||
/* Increment API restart counter */
|
||||
char *scnt = getenv("VILLAS_API_RESTART_COUNT");
|
||||
int cnt = scnt ? atoi(scnt) : 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue