* GNU General Public License for more details.
*/
+#include <libubox/blobmsg_json.h>
#include <libubox/avl-cmp.h>
#include "procd.h"
#include "service.h"
struct blob_attr *cur;
int rem;
- s->trigger = tb[SERVICE_SET_TRIGGER];
+ if (s->trigger)
+ trigger_del(s);
+
+ if (tb[SERVICE_SET_TRIGGER] && blobmsg_data_len(tb[SERVICE_SET_TRIGGER])) {
+ s->trigger = tb[SERVICE_SET_TRIGGER];
+ trigger_add(s->trigger, s);
+ }
if (tb[SERVICE_SET_INSTANCES]) {
if (!add)
{
vlist_flush_all(&s->instances);
avl_delete(&services, &s->avl);
+ trigger_del(s);
free(s->config);
free(s);
}
return;
c = blobmsg_open_table(&b, s->name);
- i = blobmsg_open_table(&b, "instances");
if (verbose && s->trigger)
blobmsg_add_blob(&b, s->trigger);
+ i = blobmsg_open_table(&b, "instances");
vlist_for_each_element(&s->instances, in, node)
instance_dump(&b, in, verbose);
blobmsg_close_table(&b, i);
{
struct job *j = container_of(t, struct job, proc.task);
- LOG("handle event %s\n", j->cmd->name);
+ DEBUG(2, "handle event %s\n", j->cmd->name);
j->cmd->handler(j, j->exec, j->env);
}