add trigger support
[project/procd.git] / instance.h
1 /*
2  * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3  * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License version 2.1
7  * as published by the Free Software Foundation
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #ifndef __PROCD_INSTANCE_H
16 #define __PROCD_INSTANCE_H
17
18 #include <libubox/vlist.h>
19 #include <libubox/uloop.h>
20 #include "utils.h"
21
22 struct service_instance {
23         struct vlist_node node;
24         struct service *srv;
25         const char *name;
26
27         int8_t nice;
28         bool valid;
29         bool restart;
30
31         struct blob_attr *config;
32         struct uloop_process proc;
33         struct uloop_timeout timeout;
34
35         struct blob_attr *command;
36         struct blob_attr *trigger;
37         struct blobmsg_list env;
38         struct blobmsg_list data;
39         struct blobmsg_list netdev;
40         struct blobmsg_list file;
41 };
42
43 void instance_start(struct service_instance *in);
44 void instance_stop(struct service_instance *in, bool restart);
45 bool instance_update(struct service_instance *in, struct service_instance *in_new);
46 void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config);
47 void instance_free(struct service_instance *in);
48 void instance_dump(struct blob_buf *b, struct service_instance *in, int debug);
49
50 #endif