Makeing program to watch for server crash?

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2009
Posts: 2
Reputation: Qvintus is an unknown quantity at this point 
Solved Threads: 0
Qvintus Qvintus is offline Offline
Newbie Poster

Makeing program to watch for server crash?

 
0
  #1
Nov 8th, 2009
Hello i have been trying to make a program that should restart my server if it crashes. Just some few problems... it won't work.
  1. Imports System.Net.Sockets
  2. Imports System.Text
  3. Module Module1
  4. Sub Main()
  5. Console.Title = "Shifty Server Keeper"
  6. Dim clientSocket As New System.Net.Sockets.TcpClient()
  7. While clientSocket.Connected = False
  8. Try
  9. clientSocket.Connect("127.0.0.1", 27015)
  10. Console.WriteLine("Running")
  11. Catch ex As Exception
  12. Console.WriteLine("Crashed")
  13. Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("ssrcds")
  14. For Each p As Process In pProcess
  15. p.Kill()
  16. Next
  17. System.Diagnostics.Process.Start("C:\....")
  18. End Try
  19. End While
  20. While clientSocket.Connected = True
  21. End While
  22. End Sub
  23. End Module

My problem is that when it notices the program runs, it won't do the process again, and just stop watching for the server crash. Please tell me a way to make it repeat
I tryet do a Do...Loop but i don't seem to do it right.
Last edited by Qvintus; Nov 8th, 2009 at 8:09 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 321
Reputation: TomW is on a distinguished road 
Solved Threads: 45
TomW TomW is offline Offline
Posting Whiz
 
0
  #2
Nov 9th, 2009
Running code in a constant/endless loop would be exactly that, your program freezing up the pc because its constantly running something over & over to search your server's status.

If keeping in a console app, I would set it up so that the windows task scheduler runs the process once at interval set times or create it as a windows process. Another option is to create a windows app on a timer basis but again, this would be a program constantly running in the background.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: Qvintus is an unknown quantity at this point 
Solved Threads: 0
Qvintus Qvintus is offline Offline
Newbie Poster
 
0
  #3
Nov 10th, 2009
So you have any eksample code i could look at to make it better or?
yea... I know the app. Timer would just freeze the program it self. while if i run it in cmd app. it works okay. The problem is just how should i put it up to get it to work?
Should i make a public function to look for connection to server. That returns true every time the program can't connect to the server, or? yea any kind of eksample that could help me to a final working program.
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 291 | Replies: 2
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC