serverspy/src/serverspy.cxx
//------------------------------------------------------------------------------
// This function will check the status of the model_server process.  
// Return values are -1, no model_server started;  0, model_server
// started and exited;  1, model_server starting up;  2, model_server
// up and registered.
//------------------------------------------------------------------------------
This function will check the status of the model_server process.
Return values are -1, no model_server started;  0, model_server
started and exited;  1, model_server starting up;  2, model_server
up and registered.
This function will check the status of the model_server process . Return values are - 1 no model_server started ; 0 model_server started and exited ; 1 model_server starting up ; 2 model_server up and registered .
int check_server_status(int init=0) {
    static int query_count = 0;
    if (init) query_count = 0;
    int service_port;
    int tcp_addr;
    if (current_server == NULL) return -1;
#ifdef _WIN32
    DWORD code;
    GetExitCodeProcess(current_server,&code);
    if(code!=STILL_ACTIVE) return 0;
#else
    if(waitpid(current_server,NULL,WNOHANG)==-1) return 0;
#endif
    int res = NameServerGetService(InternalServiceName(),service_port,tcp_addr);
    if(res==1) {
        return 2;
    } else {
        query_count++;
        if(query_count>=20000) {
            terminate_service_process(current_server);
            query_count = 0;
            return 0;
        }
        return 1;
    }
}
int check_server_status ( int init = 0 ) { static int query_count = 0 ; if ( init ) query_count = 0 ; int service_port ; int tcp_addr ; if ( current_server == NULL ) return -1 ; #ifdef _WIN32 DWORD code ; GetExitCodeProcess ( current_server , & code ) ; if ( code != STILL_ACTIVE ) return 0 ; #else if ( waitpid ( current_server , NULL , WNOHANG ) == -1 ) return 0 ; #endif int res = NameServerGetService ( InternalServiceName ( ) , service_port , tcp_addr ) ; if ( res == 1 ) { return 2 ; } else { query_count ++ ; if ( query_count >= 20000 ) { terminate_service_process ( current_server ) ; query_count = 0 ; return 0 ; } return 1 ; } }
This function will check the status of the model_server process.
This function will check the status of the model_server process .
// Check if registered in the name server // 3000 times GetService fails - timeout (0.25 sec per call, // call every second, so 60 minutes)