示例#1
0
static bool
on_timeout_cmd(void *data)
{
    const char *cmd;
    const char *param;

    cmd = cmds[cur_cmd++];
    param = cmds[cur_cmd++];

    printf("Firing new command: %s %s\n", cmd, param);

    if (!strcmp(cmd, "monitor"))
        sol_platform_add_service_monitor(on_service_changed, param, NULL);
    else if (!strcmp(cmd, "stop-monitor"))
        sol_platform_del_service_monitor(on_service_changed, param, NULL);
    else if (!strcmp(cmd, "start"))
        sol_platform_start_service(param);
    else if (!strcmp(cmd, "stop"))
        sol_platform_stop_service(param);
    else if (!strcmp(cmd, "restart"))
        sol_platform_restart_service(param);
    else if (!strcmp(cmd, "target"))
        sol_platform_set_target(param);

    if (n_cmds - cur_cmd >= 2)
        return true;

    timeout_handle = NULL;
    return false;
}
示例#2
0
static int
platform_service_stop_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
{
    struct platform_service_data *mdata = data;

    if (!mdata->service_name) {
        return sol_flow_send_error_packet(mdata->node, EINVAL,
            "Service name not set");
    }

    return sol_platform_stop_service(mdata->service_name);
}