Example #1
0
/* Ask ccnet daemon to quit, and disconnect client from daemon. */
void
stop_ccnet (void)
{
    CcnetClient *client = applet->client;
    CcnetClient *sync_client = applet->sync_client;
    
    if (!client)
        return;

    if (client->connected) {
        stop_mq_client ();
        
        send_command ("shutdown");
        ccnet_client_disconnect_daemon (client);
        if (sync_client && sync_client->connected)
            ccnet_client_disconnect_daemon (sync_client);

        trayicon_rotate (FALSE);

        rm_client_fd_from_mainloop ();
    }

    if (applet->heartbeat_monitor_on)
        stop_heartbeat_monitor ();

    trayicon_set_ccnet_state (CCNET_STATE_DOWN);
}
static void
on_ccnet_daemon_down ()
{
    stop_process_monitor ();
    disconnect_clients ();
    rm_client_fd_from_mainloop ();

    seaf_message ("restarting ccnet server ...\n");

    /* restart ccnet */
    if (seaf_controller_start () < 0) {
        seaf_warning ("Failed to restart ccnet server.\n");
        controller_exit (1);
    }
}