/usr/include/Ice/Service.h is in libzeroc-ice-dev 3.7.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | // **********************************************************************
//
// Copyright (c) 2003-2017 ZeroC, Inc. 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/Initialize.h>
#include <Ice/LoggerUtil.h>
#ifdef _WIN32
# include <winsvc.h>
#endif
namespace Ice
{
class ICE_API Service
{
public:
Service();
virtual ~Service();
//
// Shutdown the service. The default implementation invokes shutdown()
// on the communicator.
//
virtual bool shutdown();
//
// Notify the service about a signal interrupt. The default
// implementation invokes shutdown().
//
virtual void interrupt();
//
// The primary entry point for services. This function examines
// the given argument vector for reserved options and takes the
// appropriate action. The reserved options are shown below.
//
// Win32:
//
// --service NAME
//
// Unix:
//
// --daemon [--nochdir] [--noclose]
//
// If --service or --daemon are specified, the program runs as
// a service, otherwise the program runs as a regular foreground
// process. Any service-specific (and Ice-specific) options
// are stripped from argv (just as for Ice::initialize()).
//
// The return value is an exit status code: EXIT_FAILURE or
// EXIT_SUCCESS.
//
int main(int, const char* const[], const InitializationData& = InitializationData(), int = ICE_INT_VERSION);
#ifdef _WIN32
int main(int, const wchar_t* const[], const InitializationData& = InitializationData(), int = ICE_INT_VERSION);
#endif
int main(const StringSeq&, const InitializationData& = InitializationData(), int = ICE_INT_VERSION);
//
// Returns the communicator created by the service.
//
Ice::CommunicatorPtr communicator() const;
//
// Returns the Service singleton.
//
static Service* instance();
//
// Indicates whether the program is running as a Win32 service or
// Unix daemon.
//
bool service() const;
//
// Returns the program name. If the program is running as a Win32
// service, the return value is the service name. Otherwise the
// return value is the executable name (i.e., argv[0]).
//
std::string name() const;
//
// Returns true if the operating system supports running the
// program as a Win32 service or Unix daemon.
//
bool checkSystem() const;
//
// Alternative entry point for services that use their own
// command-line options. Instead of invoking main(), the
// program processes its command-line options and invokes
// run(). To run as a Win32 service or Unix daemon, the
// program must first invoke configureService() or
// configureDaemon(), respectively.
//
// The return value is an exit status code: EXIT_FAILURE or
// EXIT_SUCCESS.
//
#ifdef _WIN32
int run(int, const wchar_t* const[], const InitializationData& = InitializationData(), int = ICE_INT_VERSION);
#endif
int run(int, const char* const[], const InitializationData& = InitializationData(), int = ICE_INT_VERSION);
#ifdef _WIN32
//
// Configures the program to run as a Win32 service with the
// given name.
//
void configureService(const std::string&);
static void setModuleHandle(HMODULE);
#else
//
// Configures the program to run as a Unix daemon. The first
// argument indicates whether the daemon should change its
// working directory to the root directory. The second
// argument indicates whether extraneous file descriptors are
// closed. If the value of the last argument is not an empty
// string, the daemon writes its process ID to the given
// filename.
//
void configureDaemon(bool, bool, const std::string&);
#endif
//
// Invoked by the CtrlCHandler.
//
virtual void handleInterrupt(int);
protected:
//
// Prepare a service for execution, including the creation and
// activation of object adapters and servants.
//
virtual bool start(int, char*[], int&) = 0;
//
// Blocks until the service shuts down. The default implementation
// invokes waitForShutdown() on the communicator.
//
virtual void waitForShutdown();
//
// Clean up resources after shutting down.
//
virtual bool stop();
//
// Initialize a communicator.
//
virtual Ice::CommunicatorPtr initializeCommunicator(int&, char*[], const InitializationData&, int);
//
// Log a system error, which includes a description of the
// current system error code.
//
virtual void syserror(const std::string&);
//
// Log an error.
//
virtual void error(const std::string&);
//
// Log a warning.
//
virtual void warning(const std::string&);
//
// Log trace information.
//
virtual void trace(const std::string&);
//
// Log a literal message.
//
virtual void print(const std::string&);
//
// Enable the CtrlCHandler to invoke interrupt() when a signal occurs.
//
void enableInterrupt();
//
// Ignore signals.
//
void disableInterrupt();
//
// Log Helpers
//
typedef LoggerOutput<Service, Service*, &Service::syserror> ServiceSysError;
typedef LoggerOutput<Service, Service*, &Service::error> ServiceError;
typedef LoggerOutput<Service, Service*, &Service::warning> ServiceWarning;
typedef LoggerOutput<Service, Service*, &Service::trace> ServiceTrace;
typedef LoggerOutput<Service, Service*, &Service::print> ServicePrint;
private:
Ice::LoggerPtr _logger;
Ice::CommunicatorPtr _communicator;
bool _nohup;
bool _service;
std::string _name;
static Service* _instance;
#ifdef _WIN32
int runService(int, const char* const[], const InitializationData&);
void terminateService(DWORD);
bool waitForServiceState(SC_HANDLE, DWORD, SERVICE_STATUS&);
void showServiceStatus(const std::string&, SERVICE_STATUS&);
SERVICE_STATUS_HANDLE _statusHandle;
std::vector<std::string> _serviceArgs;
InitializationData _initData;
public:
void serviceMain(int, const wchar_t* const[]);
void control(int);
#else
int runDaemon(int, char*[], const InitializationData&, int);
bool _changeDirectory;
bool _closeFiles;
std::string _pidFile;
#endif
};
} // End of namespace Ice
#endif
|