| Revision 1889,
911 bytes
checked in by chris, 5 years ago
(diff) |
|
Record the exit status of the daemon when running as a service, and
return it to Windows so that Windows doesn't tell the admin that
"the service did not report an error" when it stopped unexpectedly.
When failing to contact the SCM, report a textual error message as
well as the error code.
Make OurService?() take a const char * instead of char *, so that we can
pass it a std::string.c_str().
InstallService? creates service using "-s" option instead of "--service",
which no longer works once we use getopt() for option processing
(to follow).
(merges [1853])
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // Win32 service functions for Box Backup, by Nick Knight |
|---|
| 2 | |
|---|
| 3 | #ifdef WIN32 |
|---|
| 4 | |
|---|
| 5 | #include "Box.h" |
|---|
| 6 | #include "BackupDaemon.h" |
|---|
| 7 | #include "MainHelper.h" |
|---|
| 8 | #include "BoxPortsAndFiles.h" |
|---|
| 9 | #include "BackupStoreException.h" |
|---|
| 10 | |
|---|
| 11 | #include "MemLeakFindOn.h" |
|---|
| 12 | |
|---|
| 13 | #include "Win32BackupService.h" |
|---|
| 14 | |
|---|
| 15 | Win32BackupService* gpDaemonService = NULL; |
|---|
| 16 | extern HANDLE gStopServiceEvent; |
|---|
| 17 | extern DWORD gServiceReturnCode; |
|---|
| 18 | |
|---|
| 19 | unsigned int WINAPI RunService(LPVOID lpParameter) |
|---|
| 20 | { |
|---|
| 21 | DWORD retVal = gpDaemonService->WinService((const char*) lpParameter); |
|---|
| 22 | gServiceReturnCode = retVal; |
|---|
| 23 | SetEvent(gStopServiceEvent); |
|---|
| 24 | return retVal; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | void TerminateService(void) |
|---|
| 28 | { |
|---|
| 29 | gpDaemonService->SetTerminateWanted(); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | DWORD Win32BackupService::WinService(const char* pConfigFileName) |
|---|
| 33 | { |
|---|
| 34 | DWORD ret; |
|---|
| 35 | |
|---|
| 36 | if (pConfigFileName != NULL) |
|---|
| 37 | { |
|---|
| 38 | ret = this->Main(pConfigFileName); |
|---|
| 39 | } |
|---|
| 40 | else |
|---|
| 41 | { |
|---|
| 42 | ret = this->Main(BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | return ret; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | #endif // WIN32 |
|---|
Note: See
TracBrowser
for help on using the repository browser.