gboolean connect_to_server (gpointer data) { if (connect_to_daemon() < 0) { return TRUE; } applet_message ("Connected to ccnet.\n"); start_seafile_daemon (); applet->auto_sync_disabled = FALSE; start_heartbeat_monitor(); start_web_server(); start_open_browser_timer (1000, NULL); return FALSE; }
/* * After spawning the ccnet.exe process; * * 1. Connect to daemon * 2. spawn seaf-daemon, sefile-web * 3. start rpc server & rpc client * 4. prompt login, if not finished yet * 5. open browser when 13420 port can be connected */ static void CALLBACK ConnDaemonProc (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime) { if (connect_to_daemon() < 0) { return; } applet_message ("Connected to ccnet.\n"); KillTimer (hwnd, iTimerID); start_seafile_daemon (); start_heartbeat_monitor (); start_web_server (); prompt_win7_tip_if_necessary (); open_browser_timer_id = SetTimer (NULL, OPEN_BROWSER_TIMER_ID, 1000, TestWebServer); }
gboolean heartbeat_monitor (void *data) { if (!applet->heartbeat_monitor_on) return FALSE; time_t now = time(NULL); if (applet->last_heartbeat == 0) { applet->last_heartbeat = now; return TRUE; } else if (now - applet->last_heartbeat > 3 * HEARTBEAT_INTERVAL) { /* hearbeat not received */ if (is_seafile_daemon_running()) { return TRUE; } else { applet_message ("[heartbeat mon] seaf-daemon is down, " "now bring it up..\n"); applet->auto_sync_disabled = FALSE; start_seafile_daemon(); } } return TRUE; }