2011-10-05 16 views
5

Come parte di alcuni script di implementazione + di test automatici che utilizzo per verificare la programmazione eseguita per un sito, ho alcuni script che aggiornano i file di configurazione di Apache. Vorrei riavviare a livello di codice WAMP in modo che le modifiche abbiano effetto. C'è un buon modo per farlo?come riavviare a livello di programmazione WAMP o Apache?

Gli script sono PowerShell.

Ciò è che cosa è nella mia cartella apache bin:

iconv 
ab.exe 
abs.exe 
ApacheMonitor.exe 
apr_dbd_odbc-1.dll 
apr_ldap-1.dll 
dbmmanage.pl 
htcacheclean.exe 
htdbm.exe 
htdigest.exe 
htpasswd.exe 
httpd.exe 
httxt2dbm.exe 
libapr-1.dll 
libapriconv-1.dll 
libaprutil-1.dll 
libeay32.dll 
libhttpd.dll 
logresolve.exe 
openssl.exe 
php.ini 
php5isapi.dll 
php5ts.dll 
rotatelogs.exe 
ssleay32.dll 
wintty.exe 
zlib1.dll 
+0

Aggiungi 'apachectl -k graceful' alla fine del tuo script? Forse dovrei chiedere prima quale tipo di script è ... – bdares

+0

È uno script PowerShell. Non vedo un apachectl.exe da nessuna parte. –

+0

È nella cartella bin apache.(Potrebbe essere chiamato 'apache2ctl'.) – bdares

risposta

3

È possibile utilizzare questo comando per il riavvio Wamp, Apache, Mysql servizi

Per Avvia servizi

NET START wampapache 
NET START wampmysqld 

per Stop Servizi

NET STOP wampapache 
NET STOP wampmysqld 
4

semplice comando di esecuzione:

httpd.exe -k riavviare

ps. questo è il mio wathdog per le finestre

@echo off 
:loop 

timeout /t 30 /nobreak 
REM . 
tasklist /FI "IMAGENAME eq php-cgi.exe" 2>NUL | find /I /N "php-cgi.exe">NUL 
if "%ERRORLEVEL%"=="1" goto Process_NotFound 


tasklist /FI "IMAGENAME eq httpd.exe" 2>NUL | find /I /N "httpd.exe">NUL 
if "%ERRORLEVEL%"=="1" goto Process_NotFound 


goto loop 



:Process_NotFound 

TASKKILL /F /IM php-cgi.exe 
TASKKILL /F /IM httpd.exe 

ping 127.0.0.1 -n 2 
Apache -k start 
ping 127.0.0.1 -n 3 
cls 
php.exe -r "$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://server.name/'); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_exec($ch);" 
ping 127.0.0.1 -n 3 
ab.exe -n 10 -c 3 http://server.name/ 

goto loop 
+0

Utile, grazie! – Mike

2

ho finito per scrivere del codice per trovare il servizio "wampapache" e riavviarlo.

public static void ResetApache() 
{ 
    ServiceUtil.RestartService("wampapache", 10000); 
} 

...

public class ServiceUtil 
{ 
    public static void RestartService(string serviceName, int msTimeout) 
    { 
     ServiceController service = new ServiceController(serviceName); 

     int startTicks = Environment.TickCount; 
     TimeSpan timeout = TimeSpan.FromMilliseconds(msTimeout); 

     if (service.Status != ServiceControllerStatus.Stopped 
      && service.Status != ServiceControllerStatus.StopPending) 
     { 
      service.Stop(); 
     } 

     service.WaitForStatus(ServiceControllerStatus.Stopped, timeout); 

     int midTicks = Environment.TickCount; 
     timeout = TimeSpan.FromMilliseconds(msTimeout - (midTicks - startTicks)); 

     service.Start(); 
     service.WaitForStatus(ServiceControllerStatus.Running, timeout); 

     //int finalTicks = Environment.TickCount; 
     //var totalTime = TimeSpan.FromTicks(finalTicks - startTicks); 

     //Console.WriteLine("Reseting process took " + (totalTime.TotalMilliseconds/1000.0) + " seconds."); 
    } 
} 
1
  1. CTRL + R -> Tipo (Comando) -> destro del mouse -> Esegui amministratore
  2. Vai al tuo WAMP Aptech bin cartella ad esempio: D: \ wamp \ bin \ apache \ apache2.4.9 \ bin >
  3. Tipo httpd.exe -d (comando Mostra tutto apache parametro)
  4. httpd.exe -k iniziare wampapache64 -n
  5. httpd.exe -k fermare wampapache64 -n
  6. httpd.exe -k restart -n wampapache64

Istruzione grafica:

primo gradino:

enter image description here

Passo Secondo:

enter image description here

Problemi correlati