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

Discussion in 'C++' started by keepyourstupidspam@yahoo.co.uk, Jul 3, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > 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
    Allan M. Bruce, Jul 3, 2006
    #2
    1. Advertising

  3. mlimber Guest

    [cross-posting deleted]

    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-lite/how-to-post.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-lite/how-to-post.html#faq-5.8.)

    Cheers! --M
    mlimber, Jul 3, 2006
    #3
  4. Guest

    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]
    >
    > 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-lite/how-to-post.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-lite/how-to-post.html#faq-5.8.)
    >
    > Cheers! --M
    , Jul 4, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sam Iam
    Replies:
    0
    Views:
    436
    Sam Iam
    Jan 31, 2004
  2. Rahmi Acar
    Replies:
    5
    Views:
    410
    Karl Heinz Buchegger
    Jul 28, 2003
  3. Aahz
    Replies:
    0
    Views:
    376
  4. kingchuffalo
    Replies:
    0
    Views:
    858
    kingchuffalo
    Sep 21, 2008
  5. Replies:
    5
    Views:
    334
Loading...

Share This Page