0

Just curious, I have 3rd party windows service that falls over every day or so (no log4net or something). It adds data to sql server database. I understand that you can restart a windows service programmatically using the ServiceController see also here. So I would monitor the sql server database with another windows service, which has a heartbeat of a minute or so and restart the 3rd party windows service, if there where no entries in the last minute. Would this be reasonable or am I over-complicating things (i.e. is there a more robust 'fix')?

Community
  • 1
  • 1
cs0815
  • 16,751
  • 45
  • 136
  • 299
  • 1
    Can't you set up this 3rd party service to restart? Each Windows service has recovery settings where you set what you want to do in case of failure. – dotnetom Oct 19 '14 at 09:19
  • Good point. Want to be careful as this is a 3rd party system in production and I do not want change any settings if possible. Btw, as mentioned there is no xml log file nor could I see any event logs. – cs0815 Oct 19 '14 at 09:25
  • Just checked - the ws is already set to restart automatically ... – cs0815 Oct 19 '14 at 11:43
  • Since we are talking about the SQL Server service, NO this is not a good approach and NO you should not mess with 3rd party services. Just because there haven't been any transaction to the server for the last minute does not mean there wont be any transactions happening in the NEXT millisecond. I do not fully understand the reason you need to restart the service but such control should be done manually by the user rather than automatically by your application. – Zaid Amir Oct 19 '14 at 11:44
  • I am not talking about a SQL Server service but a windows service! Manual is not really an option or do you want to employ someone to restart the windows service for you?! – cs0815 Oct 19 '14 at 11:45
  • When you say it "falls over", what are the symptoms? – RenniePet Oct 19 '14 at 12:13
  • That's the question. The sql database table just does not get any more values, there is no event logs that something bad happened. The 3rd party windows service is set to automatically restart but only a manual restart seems to solve the issue. As manual restart is not acceptable/practical, I was thinking about monitoring the sql db table using dapper or so and if there were no entries in the last n minutes I would restart the 3rd party ws via .Net. – cs0815 Oct 19 '14 at 12:22
  • 1
    Does this service program work if started as an ordinary console program? (Many Windows service programs have this ability built in, mostly as a debugging aid, so the developers can test the program without having to install it as a service.) If so, then you can write a program to start it as a process, and that gives you more options for monitoring it, and makes it easier to kill it and restart it. Not a complete solution, but maybe a partial solution. (And if you want to answer a comment, remember to type @ and the first letter, then click on the commenter's name in the little popup.) – RenniePet Oct 21 '14 at 07:30
  • Thanks RenniePet. Sounds a bit like a hack. – cs0815 Oct 21 '14 at 07:44

0 Answers0