| 1 |
/*******************************************************/ |
/*******************************************************/ |
| 2 |
/* */ |
/* */ |
| 3 |
/* LeafOK Innd */ |
/* LeafOK Innbbsd */ |
|
/* Copyright (C) LeafOK.com, 2003-2004 */ |
|
| 4 |
/* */ |
/* */ |
| 5 |
/* Programmed by Leaf */ |
/* Copyright (C) LeafOK.com, 2003-2008 */ |
|
/* E-mail:leaf@leafok.com QQ:6049044 */ |
|
| 6 |
/* */ |
/* */ |
| 7 |
/* http://bbs.leafok.com */ |
/* http://www.leafok.com */ |
|
/* http://bbs.leafok.net */ |
|
|
/* http://bbs.fenglin.info */ |
|
| 8 |
/* */ |
/* */ |
| 9 |
/*******************************************************/ |
/*******************************************************/ |
| 10 |
|
|
| 11 |
#include "StdAfx.h" |
#include "StdAfx.h" |
| 12 |
#include ".\service.h" |
#include ".\service.h" |
| 13 |
|
#include ".\App_common.h" |
| 14 |
|
|
| 15 |
using namespace std; |
using namespace std; |
| 16 |
|
|
| 17 |
service::service(void) |
service::service(void) |
| 18 |
:CNTService("Innd Service") |
:CNTService(App_common::ServiceName) |
| 19 |
{ |
{ |
| 20 |
|
this->m_iMajorVersion = App_common::Ver_Major; |
| 21 |
|
this->m_iMinorVersion = App_common::Ver_Minor; |
| 22 |
} |
} |
| 23 |
|
|
| 24 |
service::~service(void) |
service::~service(void) |
| 27 |
|
|
| 28 |
void service::Run() |
void service::Run() |
| 29 |
{ |
{ |
| 30 |
|
int startup_err_count = 0; |
| 31 |
|
|
| 32 |
this->ctrld.StartupDelay(); |
this->ctrld.StartupDelay(); |
| 33 |
|
|
| 34 |
this->ctrld.InitThreadPool(); |
this->ctrld.InitThreadPool(); |
| 35 |
|
|
| 36 |
if (this->ctrld.begin() == 0) |
while (this->m_bIsRunning) |
|
{ |
|
|
syslog << logfile::log_head << "Begin CONTROL ... OK" << endl; |
|
|
} |
|
|
else |
|
| 37 |
{ |
{ |
| 38 |
syslog << logfile::log_head << "Begin CONTROL ... Failed" << endl; |
if (this->ctrld.begin() == 0) |
| 39 |
} |
{ |
| 40 |
|
syslog << logfile::log_head << "Begin CONTROLD ... OK" << endl; |
| 41 |
|
|
| 42 |
|
this->ctrld.StartupChild(); |
| 43 |
|
|
| 44 |
|
break; |
| 45 |
|
} |
| 46 |
|
syslog << logfile::log_head << "Begin CONTROLD ... Failed" << endl; |
| 47 |
|
|
| 48 |
|
if (startup_err_count++ > 5) |
| 49 |
|
{ |
| 50 |
|
this->m_bIsRunning = false; |
| 51 |
|
break; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
this->ctrld.StartupChild(); |
Sleep(1000 * 60 * 5); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
while (this->m_bIsRunning && this->ctrld.IsRunning()) |
while (this->m_bIsRunning && this->ctrld.IsRunning()) |
| 58 |
{ |
{ |
| 59 |
Sleep(100); |
Sleep(100); |
| 60 |
} |
} |
| 61 |
|
|
| 62 |
this->ctrld.ShutdownChild(); |
this->ctrld.ShutdownChild(); |
| 63 |
|
|
| 64 |
if (this->ctrld.end() == 0) |
if (this->ctrld.end() == 0) |
| 65 |
{ |
{ |
| 66 |
syslog << logfile::log_head << "End CONTROL ... OK" << endl; |
syslog << logfile::log_head << "End CONTROLD ... OK" << endl; |
| 67 |
} |
} |
| 68 |
else |
else |
| 69 |
{ |
{ |
| 70 |
syslog << logfile::log_head << "End CONTROL ... Failed" << endl; |
syslog << logfile::log_head << "End CONTROLD ... Failed" << endl; |
| 71 |
} |
} |
| 72 |
|
|
| 73 |
this->ctrld.CleanupThreadPool(); |
this->ctrld.CleanupThreadPool(); |