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