int LshttpdMain::checkRestartReq() { MainServerConfig &MainServerConfigObj = MainServerConfig::getInstance(); ChildProc *pProc; // LinkedObj * pPrev = m_childrenList.head(); pProc = (ChildProc *)m_childrenList.begin(); while (pProc) { if (((ServerInfo *)pProc->m_pBlackBoard)->getRestart()) { LS_NOTICE("Child Process:%d request a graceful server restart ...", pProc->m_pid); const char *pAdminEmails = MainServerConfigObj.getAdminEmails(); if ((pAdminEmails) && (*pAdminEmails)) { char achSubject[512]; static struct utsname s_uname; memset(&s_uname, 0, sizeof(s_uname)); if (uname(&s_uname) == -1) LS_WARN("uname() failed!"); ls_snprintf(achSubject, sizeof(achSubject) - 1, "LiteSpeed Web server %s on %s restarts " "automatically to fix 503 Errors", MainServerConfigObj.getServerName(), s_uname.nodename); EmailSender::send( achSubject, pAdminEmails, ""); } gracefulRestart(); return 0; } // pPrev = pProc; pProc = (ChildProc *)pProc->next(); } return 0; }
void LshttpdMain::onGuardTimer() { MainServerConfig &MainServerConfigObj = MainServerConfig::getInstance(); static int s_count = 0; DateTime::s_curTime = time(NULL); //#if !defined( RUN_TEST ) if (m_pidFile.testAndRelockPidFile(PID_FILE, m_pid)) { LS_NOTICE("Failed to lock PID file, restart server gracefully ..."); gracefulRestart(); return; } //#endif CgidWorker::checkRestartCgid(MainServerConfigObj.getServerRoot(), MainServerConfigObj.getChroot(), ServerProcessConfig::getInstance().getPriority()); HttpLog::onTimer(); m_pServer->onVHostTimer(); s_count = (s_count + 1) % 5; clearToStopApp(); //processAdminCtrlFile( m_sCtrlFile.c_str()); checkRestartReq(); }
int LshttpdMain::processAdminCmd( char * pCmd, char * pEnd, int &apply ) { if ( strncasecmp( pCmd, "reload:", 7 ) == 0 ) { apply = 1; pCmd += 7; if ( strncasecmp( pCmd, "config", 6 ) == 0 ) { LOG_NOTICE(( "Reload configuration request from admin interface!" )); reconfig(); } /* COMMENT: Not support reconfigVHost NOW. else if ( strncasecmp( pCmd, "vhost:", 6 ) == 0 ) { pCmd += 6; LOG_NOTICE(( "Reload configuration for virtual host %s!", pCmd )); if ( m_pBuilder->loadConfigFile( NULL ) == 0 ) m_pServer->reconfigVHost( pCmd, m_pBuilder->getRoot() ); //m_pBuilder->reconfigVHost( pCmd ); }*/ } else if ( strncasecmp( pCmd, "enable:", 7 ) == 0 ) { apply = 1; pCmd += 7; if ( strncasecmp( pCmd, "vhost:", 6 ) == 0 ) { pCmd += 6; if ( !m_pServer->enableVHost( pCmd, 1 ) ) LOG_NOTICE(( "Virtual host %s is enabled!", pCmd )); else LOG_ERR(( "Virtual host %s can not be enabled, reload first!", pCmd )); } } else if ( strncasecmp( pCmd, "disable:", 8 ) == 0 ) { apply = 1; pCmd += 8; if ( strncasecmp( pCmd, "vhost:", 6 ) == 0 ) { pCmd += 6; if ( !m_pServer->enableVHost( pCmd, 0 ) ) LOG_NOTICE(( "Virtual host %s is disabled!", pCmd )); else LOG_ERR(( "Virtual host %s can not be disabled, reload first!", pCmd )); } } else if ( strncasecmp( pCmd, "restart", 7 ) == 0 ) { LOG_NOTICE(( "Server restart request from admin interface!" )); gracefulRestart(); } else if ( strncasecmp( pCmd, "toggledbg", 7 ) == 0 ) { LOG_NOTICE(( "Toggle debug logging request from admin interface!" )); broadcastSig( SIGUSR2, 0 ); apply = 0; } return 0; }