File tree 1 file changed +58
-0
lines changed
1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Code is not commented but still so easy to understand reading the COUTS
3
+ */
4
+ #ifdef _WIN32
5
+ #include < Windows.h>
6
+ #else
7
+ #include < unistd.h>
8
+ #endif
9
+ #include < iostream>
10
+ #include < cstdlib>
11
+ #include < string.h>
12
+ #include < fstream>
13
+ #include < stdlib.h>
14
+ using namespace std ;
15
+ // **********************************************************************************************************
16
+
17
+ int main (){
18
+ int time = 10000 ; // 1800000 = 30min 3600000 = 1h 10000 = 10s
19
+ cout << " HTTPD Will restart every 30 minutes" ;
20
+ while (1 ){
21
+ // interactive wait
22
+
23
+ cout << endl << " Restarting in: 30 min" << endl;
24
+ Sleep (300000 );
25
+ cout << " Restarting in: 25 min" << endl;
26
+ Sleep (300000 );
27
+ cout << " Restarting in: 20 min" << endl;
28
+ Sleep (300000 );
29
+ cout << " Restarting in: 15 min" << endl;
30
+ Sleep (300000 );
31
+ cout << " Restarting in: 10 min" << endl;
32
+ Sleep (300000 );
33
+ cout << " Restarting in: 5 min" << endl;
34
+ Sleep (300000 );
35
+ cout << " RESTARTING SERVER!" ;
36
+
37
+ ifstream archivo;
38
+ string texto;
39
+ archivo.open (" C:\\ xampp\\ apache\\ logs\\ httpd.pid" ,ios::in);
40
+ if (archivo.fail ()){
41
+ cout << " Could not read the PID from C:\\ xampp\\ apache\\ logs\\ httpd.pid, starting" <<endl;
42
+ } else {
43
+ cout << " PID Read performed. Stopping" <<endl;
44
+ getline (archivo,texto);
45
+ cout << texto << endl;
46
+ string cmd = " C:\\ windows\\ system32\\ taskkill.exe -F -PID " + texto + " >nul 2>&1" ;
47
+ system (cmd.c_str ());
48
+ cout << " HTTPD Stopped successfully" <<endl;
49
+ }
50
+ // To avoid getting massive CMD windows opent, we end the cmds
51
+ cout << " Closing extra terminals" <<endl;
52
+ system (" C:\\ windows\\ system32\\ taskkill.exe /IM cmd.exe" );
53
+ cout << " HTTPD Starting" <<endl;
54
+ system (" start C:\\ xampp\\ apache_start.bat" );
55
+ archivo.close ();
56
+ // Sleep(time);
57
+ }
58
+ }
You can’t perform that action at this time.
0 commit comments