|
-
Oct 30th, 2008, 02:04 PM
#1
Thread Starter
Frenzied Member
Way to have a service restart itself?
Is there a way to program a service to restart itself? I am talking to some third party hardware/software, and if a connection gets lost, the software doesn't want to reset itself correctly unless a shut down and restart the service completely. Basically I want to test for a valid binding, and if it has failed, do a self restart. Is it possible, or do I have to write a second service that looks for some kind of flag and resets the first service if it finds it? Thanks.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Oct 30th, 2008, 02:16 PM
#2
Re: Way to have a service restart itself?
I know services have built in fault recovery if that is what you mean.
When you go into services.msc, open up any services properties, and go to the recovery tab for the available options. You may be able to use this to meet your needs?
-
Oct 30th, 2008, 02:25 PM
#3
Thread Starter
Frenzied Member
Re: Way to have a service restart itself?
 Originally Posted by kleinma
I know services have built in fault recovery if that is what you mean.
When you go into services.msc, open up any services properties, and go to the recovery tab for the available options. You may be able to use this to meet your needs?
Hmmm...anybody know how to tell a service it is in fault? Will an uncaught exception do it?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Oct 30th, 2008, 04:41 PM
#4
Re: Way to have a service restart itself?
 Originally Posted by SeanGrebey
Is there a way to program a service to restart itself? I am talking to some third party hardware/software, and if a connection gets lost, the software doesn't want to reset itself correctly unless a shut down and restart the service completely. Basically I want to test for a valid binding, and if it has failed, do a self restart. Is it possible, or do I have to write a second service that looks for some kind of flag and resets the first service if it finds it? Thanks.
It sounds like you have a bad design and shouldn't be resolved by trying to just restart itself.
Why couldn't you handle this yourself in your service? If your service loses the connection then why can't the service just reconnect? Just restarting it isn't a very good solution.
 Originally Posted by SeanGrebey
Hmmm...anybody know how to tell a service it is in fault? Will an uncaught exception do it?
The service kind of won't work if it's faulting... at least I believe that's how it works.
-
Oct 30th, 2008, 04:47 PM
#5
Re: Way to have a service restart itself?
I agree that unless it is a really poorly made 3rd party thing you are working with, there should be some way in your code to restart the connection without needing to restart the service. You may be just be going about this the wrong way.
-
Oct 31st, 2008, 08:51 AM
#6
Thread Starter
Frenzied Member
Re: Way to have a service restart itself?
 Originally Posted by kasracer
It sounds like you have a bad design and shouldn't be resolved by trying to just restart itself.
Why couldn't you handle this yourself in your service? If your service loses the connection then why can't the service just reconnect? Just restarting it isn't a very good solution.
The service kind of won't work if it's faulting... at least I believe that's how it works.
I didn't write the 3rd party library, I don't know what is going on behind the scenes, I don't know why it isn't releasing correctly, but once you have created a connection and it fails, it won't successfully create another one until the service has been restarted. It is not a particularly good solution to restart the service, but I don't have a lot of options at this point. There aren't any reconnects in their library. All I can do is destroy their objects and recreate them, but that doesn't work. They won't reconnect once they are recreated. I am open to any better ideas, but until then I have a deadline and this will resolve it.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Oct 31st, 2008, 08:53 AM
#7
Re: Way to have a service restart itself?
If you can post some code where you try to do your destroy/recreate, then maybe something will stick out... but short of that, I don't really have any suggestions other than contacting the people who made the component you are interfacing with.
-
Oct 31st, 2008, 08:53 AM
#8
Thread Starter
Frenzied Member
Re: Way to have a service restart itself?
 Originally Posted by kleinma
I agree that unless it is a really poorly made 3rd party thing you are working with, there should be some way in your code to restart the connection without needing to restart the service. You may be just be going about this the wrong way.
I believe I am the first developer to use it...
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Oct 31st, 2008, 08:59 AM
#9
Thread Starter
Frenzied Member
Re: Way to have a service restart itself?
 Originally Posted by kleinma
If you can post some code where you try to do your destroy/recreate, then maybe something will stick out... but short of that, I don't really have any suggestions other than contacting the people who made the component you are interfacing with.
Yeah I have an e-mail in to three of their developers right now asking them what steps I need to follow to recreate a connection. They usually answer pretty quickly, but it has been almost a day now, so I am getting a creeping suspicion they aren't entirely sure.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|