473,748 Members | 8,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why the service control manager doesn't start my service

Hi, all,

I have a question, and I hope to get some hints here..

I created a really simple service just to check why the service manager
doesn't start my service the second time if the first time failed..

I created an atl service through the wizard, and the only thing I do is
override the PreMessageLoop( )...

HRESULT CAutoStartServi ceModule::PreMe ssageLoop(int nShowCmd)
{
HRESULT hr = CAtlServiceModu leT<CAutoStartS erviceModule,
IDS_SERVICENAME >::PreMessageLo op(nShowCmd);
if(FAILED(hr)) return hr;

//return a false here..
//log event here..
LogEvent(_T("Fa iled to start the service, should retry ...."));
return E_ABORT;
}
And in the service control panel, i set "Recovery options" as

First Failure: Restart the service..
Second Failure: Restart the service..
Subsequent Failure: Restart the service..

But the service was not restarted ...

I wonder maybe I miss something to report the right information back to
the service control manager..

Thanks for any help..

J.W.
Sep 18 '06 #1
4 2907
I Jinwei,

see inline

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
Hi, all,

I created a really simple service just to check why the service manager
doesn't start my service the second time if the first time failed..

I created an atl service through the wizard, and the only thing I do is
override the PreMessageLoop( )...

HRESULT CAutoStartServi ceModule::PreMe ssageLoop(int nShowCmd)
{
HRESULT hr = CAtlServiceModu leT<CAutoStartS erviceModule,
IDS_SERVICENAME >::PreMessageLo op(nShowCmd);
if(FAILED(hr)) return hr;

//return a false here..
//log event here..
LogEvent(_T("Fa iled to start the service, should retry ...."));
return E_ABORT;
}

And in the service control panel, i set "Recovery options" as

First Failure: Restart the service..
Second Failure: Restart the service..
Subsequent Failure: Restart the service..
Recover options are only relevant if your service executable crashes, not
because of any HRESULTs which might lead to ending a process. If a process
is just ending by leaving all thread functions that is pretty OK for the
service control manager.

You could try something like int *p = NULL; *p = 42; that should crash your
service and the restart should occur after the configured time interval.
Defaults to 1 minute IIRC.

--
SvenC
But the service was not restarted ...

I wonder maybe I miss something to report the right information back to
the service control manager..

Thanks for any help..

J.W.

Sep 18 '06 #2
Thanks, SvenC,

That definitely help, it seems that I may have to write some watchdong
service to watch the state of my service..

Thanks agian,

Jianwei

SvenC wrote:
I Jinwei,

see inline

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:%2******** **********@TK2M SFTNGP04.phx.gb l...
>Hi, all,

I created a really simple service just to check why the service manager
doesn't start my service the second time if the first time failed..

I created an atl service through the wizard, and the only thing I do is
override the PreMessageLoop( )...

HRESULT CAutoStartServi ceModule::PreMe ssageLoop(int nShowCmd)
{
HRESULT hr = CAtlServiceModu leT<CAutoStartS erviceModule,
IDS_SERVICENAM E>::PreMessageL oop(nShowCmd);
if(FAILED(hr)) return hr;

//return a false here..
//log event here..
LogEvent(_T("Fa iled to start the service, should retry ...."));
return E_ABORT;
}

And in the service control panel, i set "Recovery options" as

First Failure: Restart the service..
Second Failure: Restart the service..
Subsequent Failure: Restart the service..

Recover options are only relevant if your service executable crashes, not
because of any HRESULTs which might lead to ending a process. If a process
is just ending by leaving all thread functions that is pretty OK for the
service control manager.

You could try something like int *p = NULL; *p = 42; that should crash your
service and the restart should occur after the configured time interval.
Defaults to 1 minute IIRC.

--
SvenC
>But the service was not restarted ...

I wonder maybe I miss something to report the right information back to
the service control manager..

Thanks for any help..

J.W.

Sep 18 '06 #3
Hi Jinwei,

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:Ol******** ******@TK2MSFTN GP04.phx.gbl...
Thanks, SvenC,

That definitely help, it seems that I may have to write some watchdong
service to watch the state of my service..
Why would you? Just change the logic how your service starts. Why do you
have any logic in your service that ends the process? Just start it up and
never shut down unless the service control manager gives you a stop signal.
If you think there is some situation where your service should not do
anything or is in an error state than try to recover within your running
service process. When something goes so wrong that your process crashes the
service control manager will restart your service (depending on the Recovery
options you chose). The service control manager is your watch dog.

--
SvenC
Thanks agian,

Jianwei

SvenC wrote:
>I Jinwei,

see inline

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:%2******* ***********@TK2 MSFTNGP04.phx.g bl...
>>Hi, all,

I created a really simple service just to check why the service manager
doesn't start my service the second time if the first time failed..

I created an atl service through the wizard, and the only thing I do is
override the PreMessageLoop( )...

HRESULT CAutoStartServi ceModule::PreMe ssageLoop(int nShowCmd)
{
HRESULT hr = CAtlServiceModu leT<CAutoStartS erviceModule,
IDS_SERVICENA ME>::PreMessage Loop(nShowCmd);
if(FAILED(hr)) return hr;

//return a false here..
//log event here..
LogEvent(_T("Fa iled to start the service, should retry ...."));
return E_ABORT;
}

And in the service control panel, i set "Recovery options" as

First Failure: Restart the service..
Second Failure: Restart the service..
Subsequent Failure: Restart the service..

Recover options are only relevant if your service executable crashes, not
because of any HRESULTs which might lead to ending a process. If a
process is just ending by leaving all thread functions that is pretty OK
for the service control manager.

You could try something like int *p = NULL; *p = 42; that should crash
your service and the restart should occur after the configured time
interval. Defaults to 1 minute IIRC.

--
SvenC
>>But the service was not restarted ...

I wonder maybe I miss something to report the right information back to
the service control manager..

Thanks for any help..

J.W.
Sep 19 '06 #4
Got it, thanks again..
SvenC wrote:
Hi Jinwei,

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:Ol******** ******@TK2MSFTN GP04.phx.gbl...
>Thanks, SvenC,

That definitely help, it seems that I may have to write some watchdong
service to watch the state of my service..

Why would you? Just change the logic how your service starts. Why do you
have any logic in your service that ends the process? Just start it up and
never shut down unless the service control manager gives you a stop signal.
If you think there is some situation where your service should not do
anything or is in an error state than try to recover within your running
service process. When something goes so wrong that your process crashes the
service control manager will restart your service (depending on the Recovery
options you chose). The service control manager is your watch dog.

--
SvenC
>Thanks agian,

Jianwei

SvenC wrote:
>>I Jinwei,

see inline

"Jianwei Sun" <js***********@ gmail.comwrote in message
news:%2****** ************@TK 2MSFTNGP04.phx. gbl...
Hi, all,

I created a really simple service just to check why the service manager
doesn't start my service the second time if the first time failed..

I created an atl service through the wizard, and the only thing I do is
override the PreMessageLoop( )...

HRESULT CAutoStartServi ceModule::PreMe ssageLoop(int nShowCmd)
{
HRESULT hr = CAtlServiceModu leT<CAutoStartS erviceModule,
IDS_SERVICEN AME>::PreMessag eLoop(nShowCmd) ;
if(FAILED(hr)) return hr;

//return a false here..
//log event here..
LogEvent(_T("Fa iled to start the service, should retry ...."));
return E_ABORT;
}

And in the service control panel, i set "Recovery options" as

First Failure: Restart the service..
Second Failure: Restart the service..
Subsequent Failure: Restart the service..
Recover options are only relevant if your service executable crashes, not
because of any HRESULTs which might lead to ending a process. If a
process is just ending by leaving all thread functions that is pretty OK
for the service control manager.

You could try something like int *p = NULL; *p = 42; that should crash
your service and the restart should occur after the configured time
interval. Defaults to 1 minute IIRC.

--
SvenC

But the service was not restarted ...

I wonder maybe I miss something to report the right information back to
the service control manager..

Thanks for any help..

J.W.
Sep 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2768
by: Russ McDaniel | last post by:
Originally posted to microsoft.public.dotnet.distributed_apps with no response. Reposted here with additional thoughts. --- Hello, I'm writing a Windows service which performs some potentially long-running, uninterruptable processes. When the service starts, I create a separate worker thread to perform the work so as to not block the service control manager upon startup. The design quandry I'm running into though is how best
7
34385
by: scarred wind | last post by:
when i run my program, an error message prompt me that i should add the installutil.exe. How do i checked for the installutil.exe? How can i add it to my Timer program? ---------------------------------------------- when you fear to fail, you fear something that has not yet happened. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
2386
by: Mrinal Kamboj | last post by:
Hi , Doubt may be bit trivial , but i wanted to know , what are the exact benefits derived while we run a background process as an NT service in windows , we can as well achieve the functionality using standalone exe , which will keep on running in a loop and do the job till been messaged to stop . Essentially , i want the key advantages of implementing process daemons as an NT Service in windows .
0
2811
by: tshad | last post by:
I have a Windows Service I created that just sets a timer and writes to EventLog every 10 seconds. It installed fine and it actually starts. But it says it doesn't. The progress bar shows the progress fine until it hits about halfway. It then stops there for about 4 or 5 seconds then goes a little farther. I then get a message: Could not start the MyService Service on Local Computer. Error 1053: The service did not respond to the...
2
4678
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property of the service is not set (this can be checked by right-clicking on the service in the Services window (Admin tools>Services), choosing Properties, LogOn tab). In order to enable my service to launch a GUI at startup, I added the following lines...
6
6478
by: uuyytt | last post by:
I have a Windows service from which I want to start Internet Explorer with a particular URL as an argument. I don't know why my code (shown below) doesn't work. I know that IExplore.exe starts as I can see it in my task manager, but it is not visible. Can anyone explain what is happening? My code: Process p = Process.Start("IExplore.exe", m_strURL);
2
1945
by: tshad | last post by:
I have a Service that starts a thread that never ends. When I stop the service from the Service Applet, does it kill the thread or do I need to do it myself? If it isn't killed, what happens when I start the service again. ************************************************** Protected Overrides Sub OnStart(ByVal args() As String) Dim theThread As Thread
13
6651
by: dancer | last post by:
I have made a new post because when I try to respond to another, I get the error, "Article Rejected -- Ill-formed message id" This is in response to the advice of Juan Libre to install Net Framework Service Pack 1 in order to use ASP.net 1.1 and the net Framework 1.1 ------------------------------------------------------------------------------------------------ I found the following file, "svcpack.log" at C:\WINNT. It contains many...
4
9694
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I've written a .net Windows service in C#. It works most of the time for most people. It is configured to automatically start when Windows boots. Sometimes it fails to start on Windows XP during boot. All I know is that it is timing out. But no useful details appear in the event log, not even my first EventLog message in OnStart. How can I figure out why it isn't starting? How can I fix this? My ServiceBase constructor just sets a few...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.