1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// **********************************************************************
//
// Copyright (c) 2003 - 2004
// ZeroC, Inc.
// North Palm Beach, FL, USA
//
// All Rights Reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_SERVICE_H
#define ICE_SERVICE_H
#include <Ice/CommunicatorF.h>
#include <Ice/LoggerF.h>
#include <fstream>
namespace Ice
{
class ICE_API Service
{
public:
Service();
virtual ~Service();
virtual bool shutdown();
virtual void interrupt();
int main(int, char*[]);
Ice::CommunicatorPtr communicator() const;
static Service* instance();
void handleInterrupt(int);
protected:
virtual bool start(int, char*[]) = 0;
virtual void waitForShutdown();
virtual bool stop();
virtual Ice::CommunicatorPtr initializeCommunicator(int&, char*[]);
void enableInterrupt();
void disableInterrupt();
void syserror(const std::string&) const;
void error(const std::string&) const;
void warning(const std::string&) const;
void trace(const std::string&) const;
#ifdef _WIN32
bool win9x() const;
private:
bool checkService(int, char*[], int&);
int installService(const std::string&, int, char*[]);
int uninstallService(const std::string&, int, char*[]);
int startService(const std::string&, int, char*[]);
int stopService(const std::string&, int, char*[]);
public:
void serviceMain(int, char*[]);
void control(int);
private:
bool _service;
bool _win9x; // Are we running on Windows 9x/ME?
SERVICE_STATUS_HANDLE _statusHandle;
SERVICE_STATUS _status;
std::vector<std::string> _serviceArgs;
#else
private:
bool checkDaemon(int, char*[], int&);
#endif
private:
std::string _prog;
Ice::LoggerPtr _logger;
Ice::CommunicatorPtr _communicator;
bool _nohup;
static Service* _instance;
};
} // End of namespace Ice
#endif
|