instance.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef __PROCD_INSTANCE_H
  15. #define __PROCD_INSTANCE_H
  16. #include <libubox/vlist.h>
  17. #include <libubox/uloop.h>
  18. #include <libubox/ustream.h>
  19. #include "../utils/utils.h"
  20. #define RESPAWN_ERROR (5 * 60)
  21. struct jail {
  22. bool procfs;
  23. bool sysfs;
  24. bool ubus;
  25. bool log;
  26. bool ronly;
  27. char *name;
  28. char *hostname;
  29. struct blobmsg_list mount;
  30. int argc;
  31. };
  32. struct service_instance {
  33. struct vlist_node node;
  34. struct service *srv;
  35. const char *name;
  36. int8_t nice;
  37. bool valid;
  38. uid_t uid;
  39. gid_t gid;
  40. bool halt;
  41. bool restart;
  42. bool respawn;
  43. int respawn_count;
  44. int reload_signal;
  45. struct timespec start;
  46. bool trace;
  47. bool has_jail;
  48. bool no_new_privs;
  49. struct jail jail;
  50. char *seccomp;
  51. char *pidfile;
  52. uint32_t term_timeout;
  53. uint32_t respawn_timeout;
  54. uint32_t respawn_threshold;
  55. uint32_t respawn_retry;
  56. struct blob_attr *config;
  57. struct uloop_process proc;
  58. struct uloop_timeout timeout;
  59. struct ustream_fd _stdout;
  60. struct ustream_fd _stderr;
  61. struct blob_attr *command;
  62. struct blob_attr *trigger;
  63. struct blobmsg_list env;
  64. struct blobmsg_list data;
  65. struct blobmsg_list netdev;
  66. struct blobmsg_list file;
  67. struct blobmsg_list limits;
  68. struct blobmsg_list errors;
  69. };
  70. void instance_start(struct service_instance *in);
  71. void instance_stop(struct service_instance *in);
  72. void instance_update(struct service_instance *in, struct service_instance *in_new);
  73. void instance_init(struct service_instance *in, struct service *s, struct blob_attr *config);
  74. void instance_free(struct service_instance *in);
  75. void instance_dump(struct blob_buf *b, struct service_instance *in, int debug);
  76. #endif