473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

windows service not starting, may be something to do with static variables

Hi,
I have written a service that can start and stop normally using net
start and net stop but when I reboot the machine the serivce does not
restart. The code seems to bomb out on the following line.

m_pFileLogAppender = new FileLogAppender(severity, logFile);
The class FileLogAppender is a singleton, actually it inherites from a
template singleton base class. I am wondering if this is the problem,
the singleton base class implements a static instance variable and
maybe this has not been initialized yet. Could this be the problem, is
there a way that I can ensure that it has been initialized. By using a
pragma maybe.

Am I on the correct path at all.

Your help yould be greatly appreciated this is really hard to debug as
the machine is rebooting.

Thanks,
Enda Mannion

Jul 3 '06 #1
3 3164

<ke****************@yahoo.co.ukwrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
Hi,
I have written a service that can start and stop normally using net
start and net stop but when I reboot the machine the serivce does not
restart. The code seems to bomb out on the following line.

m_pFileLogAppender = new FileLogAppender(severity, logFile);
The class FileLogAppender is a singleton, actually it inherites from a
If FileLogAppender is a singleton, why are you creating a new instance of
it? A singleton is normally accessed by something like:
FileLogAppender::GetInstance()

This could indeed be your problem depending on the imlpementation of
FileLogAppender
Allan
Jul 3 '06 #2
[cross-posting deleted]

ke****************@yahoo.co.uk wrote:
I have written a service that can start and stop normally using net
start and net stop but when I reboot the machine the serivce does not
restart. The code seems to bomb out on the following line.

m_pFileLogAppender = new FileLogAppender(severity, logFile);
The class FileLogAppender is a singleton, actually it inherites from a
template singleton base class. I am wondering if this is the problem,
the singleton base class implements a static instance variable and
maybe this has not been initialized yet. Could this be the problem, is
there a way that I can ensure that it has been initialized. By using a
pragma maybe.

Am I on the correct path at all.

Your help yould be greatly appreciated this is really hard to debug as
the machine is rebooting.
Windows, net start/stop, services, etc. are off-topic in this newsgroup
(see this FAQ:
http://www.parashift.com/c++-faq-lit....html#faq-5.9), but
you may have an on-topic C++ language question here. Can you reduce the
failure to a *minimal* but *complete* compilable sample that you could
post here for us to inspect? (Compare these code posting tips:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8.)

Cheers! --M

Jul 3 '06 #3
I have changed my implementation of the singleton class, now I use
::Instance() to return a pointer to the class instance instead of using
new.

But the service is still not starting up on a reboot. My implementation
works fine when I use net start when the machine is already running.

On a reboot the code terminates when I try to reference the singleton.

Anyone have any ideas, is there any pragmas I can use??

Thanks,
Enda

mlimber wrote:
[cross-posting deleted]

ke****************@yahoo.co.uk wrote:
I have written a service that can start and stop normally using net
start and net stop but when I reboot the machine the serivce does not
restart. The code seems to bomb out on the following line.

m_pFileLogAppender = new FileLogAppender(severity, logFile);
The class FileLogAppender is a singleton, actually it inherites from a
template singleton base class. I am wondering if this is the problem,
the singleton base class implements a static instance variable and
maybe this has not been initialized yet. Could this be the problem, is
there a way that I can ensure that it has been initialized. By using a
pragma maybe.

Am I on the correct path at all.

Your help yould be greatly appreciated this is really hard to debug as
the machine is rebooting.

Windows, net start/stop, services, etc. are off-topic in this newsgroup
(see this FAQ:
http://www.parashift.com/c++-faq-lit....html#faq-5.9), but
you may have an on-topic C++ language question here. Can you reduce the
failure to a *minimal* but *complete* compilable sample that you could
post here for us to inspect? (Compare these code posting tips:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8.)

Cheers! --M
Jul 4 '06 #4

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

Similar topics

9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
1
by: Tim Smith | last post by:
I have an application for which the main thread apartment threading must be static. This is since it calls a DLL which if I switch to MTAThread it is very slow, and cannot run in a thread as...
4
by: Gav | last post by:
Hi All, Just starting to look at writing windows services if you stop the service and build the project, do I have to run the installutil again or can I just start the service again? Thanks...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
3
by: junior lopes | last post by:
i have 2 applications , 1º is in windows service and the other is windows application. i need to start, stop and pause service from windows application. i have done that,but the problem is when i...
3
by: sokolo | last post by:
Hello, I wrote a windows service application however it is not working. The service is supposed to enter a new task every 5 sec within Microsoft Outlook. Here is the code for application: ...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.