/* 停止某个服务进程 */ static int proctl_monitor_cmd_stop(ACL_VSTREAM *client, const char *filepath, const char *args) { const char *myname = "proctl_monitor_cmd_stop"; if (filepath == NULL || *filepath == 0) { acl_vstream_fprintf(client, "-ERR|filepath null\r\n"); acl_msg_error("%s(%d): no filepath", myname, __LINE__); return (-1); } if (strcasecmp(filepath, "all") == 0) { acl_msg_info("begin to stop file(%s)", filepath); proctl_monitor_stop_all_service(client); } else if (!proctl_service_exist(filepath)) { acl_msg_error("%s(%d): filepath(%s) not running now", myname, __LINE__, filepath); acl_vstream_fprintf(client, "-ERR|filepath(%s) not running\r\n", filepath); return (-1); } acl_msg_info("%s(%d): begin to stop file(%s)", myname, __LINE__, filepath); proctl_monitor_stop_service(client, filepath, args); acl_msg_info("%s(%d): stop (%s) end", myname, __LINE__, filepath); return (0); }
static int proctl_monitor_cmd_probe(ACL_VSTREAM *client, const char *filepath) { if (filepath == NULL || *filepath == 0) { acl_vstream_fprintf(client, "-ERR|filepath is null\r\n"); return (-1); } if (proctl_service_exist(filepath)) acl_vstream_fprintf(client, "+OK|service: %s is running\r\n", filepath); else acl_vstream_fprintf(client, "+OK|service: %s is not running\r\n", filepath); return (0); }
int acl_proctl_deamon_start_one(const char *progchild, int argc, char *argv[]) { const char *myname = "acl_proctl_deamon_start_one"; PROCTL_SERVICE *service; if (proctl_service_exist(progchild)) { acl_msg_error("%s(%d): child(%s) maybe be running!", myname, __LINE__, progchild); return (-1); } service = proctl_service_new(progchild, argc, argv); if (proctl_service_start(service) < 0) { proctl_service_free(service); return (-1); } return (0); }
/* 通知主线程,启动一个服务 */ static int proctl_monitor_cmd_start(ACL_VSTREAM *client, const char *filepath, const char *args) { const char *myname = "proctl_monitor_cmd_start"; ACL_VSTRING *cmdline; PROCTL_SERVICE *service; PROCTL_MSG *msg; if (filepath[0] == 0) { acl_vstream_fprintf(client, "-ERR|filepath null\r\n"); acl_msg_error("%s(%d): no filepath", myname, __LINE__); return (-1); } if (proctl_service_exist(filepath)) { acl_msg_error("%s(%d): child(%s) maybe be running!", myname, __LINE__, filepath); acl_vstream_fprintf(client, "-ERR|child(%s) maybe be running!\r\n", filepath); return (-1); } cmdline = acl_vstring_alloc(256); acl_vstring_strcpy(cmdline, "\""); acl_vstring_strcat(cmdline, filepath); acl_vstring_strcat(cmdline, "\""); if (args && *args) { acl_vstring_strcat(cmdline, " "); acl_vstring_strcat(cmdline, args); } service = proctl_service_alloc(filepath, cmdline); msg = proctl_msg_new(PROCTL_MSG_START); msg->service = service; proctl_msg_push(msg); return (0); }