void LshttpdMain::gracefulRestart() { LS_DBG_L("Graceful Restart... "); close(m_fdAdmin); broadcastSig(SIGTERM, 1); s_iRunning = 0; m_pidFile.closePidFile(); m_pServer->passListeners(); int pid = fork(); if (!pid) { char achCmd[1024]; int fd = StdErrLogger::getInstance().getStdErr(); if (fd != 2) close(fd); int len = getFullPath("bin/litespeed", achCmd, 1024); achCmd[len - 10] = 0; chdir(achCmd); achCmd[len - 10] = '/'; if (execl(achCmd, "litespeed", NULL)) LS_ERROR("Failed to start new instance of LiteSpeed Web server!"); exit(0); } if (pid == -1) LS_ERROR("Failed to restart the server!"); }
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; }
void LshttpdMain::stopAllChildren() { ChildProc *pProc; broadcastSig(SIGTERM, 0); long tmBeginWait = time(NULL); long tmEndWait = tmBeginWait + 300 + HttpServerConfig::getInstance().getRestartTimeout(); while ((s_iRunning != -1) && (m_childrenList.size() > 0) && (time(NULL) < tmEndWait)) { sleep(1); waitChildren(); } if (m_childrenList.size() > 0) { pProc = (ChildProc *)m_childrenList.begin(); while (pProc) { kill(pProc->m_pid, SIGKILL); cleanUp(pProc->m_pid, pProc->m_pBlackBoard); pProc = (ChildProc *)pProc->next(); } } }
void LshttpdMain::applyChanges() { LS_DBG_L("Applying new configuration. "); broadcastSig(SIGTERM, 1); }
void LshttpdMain::applyChanges() { if ( D_ENABLED( DL_LESS ) ) LOG_D(( "Applying new configuration. " )); broadcastSig( SIGTERM, 1 ); }