| 1 | use strict; | ||
| 2 | package Xpriori::XMS::ServerUtil::Win32; | ||
| 3 | use Win32::Service; | ||
| 4 | sub new($) | ||
| 5 | { | ||
| 6 | return bless {}, shift(@_); | ||
| 7 | } | ||
| 8 | sub startServer($) | ||
| 9 | { | ||
| 10 | my ($oSelf) = @_; | ||
| 11 | return Win32::Service::StartService('', 'NeoServer'); | ||
| 12 | } | ||
| 13 | sub stopServer($) | ||
| 14 | { | ||
| 15 | my ($oSelf) = @_; | ||
| 16 | return Win32::Service::StopService('', 'NeoServer'); | ||
| 17 | } | ||
| 18 | sub getStatus($) | ||
| 19 | { | ||
| 20 | my ($oSelf) = @_; | ||
| 21 | my $iStsW = $oSelf->getStatusWin(); | ||
| 22 | return ($iStsW == 1)? 0 : 1; #STOPPED or NOT | ||
| 23 | } | ||
| 24 | sub createDb($$$) | ||
| 25 | { | ||
| 26 | my($oSelf, $sNeoHome, $sPasswd) = @_; | ||
| 27 | return qx{${sNeoHome}/bin/neoXMLUtils CreateDB_batch ${sNeoHome}/config ${sPasswd} AC_ON}; | ||
| 28 | } | ||
| 29 | sub getStatusWin($) | ||
| 30 | { | ||
| 31 | my ($oSelf) = @_; | ||
| 32 | my %hRes; | ||
| 33 | Win32::Service::GetStatus('', 'NeoServer', \%hRes); | ||
| 34 | $hRes{CurrentStateText} = | ||
| 35 | $oSelf->getStatusWinTxt($hRes{CurrentState}); | ||
| 36 | return (wantarray())? %hRes : $hRes{CurrentState}; | ||
| 37 | } | ||
| 38 | sub getStatusWinTxt($$) | ||
| 39 | { | ||
| 40 | my($oSelf, $iSts) = @_; | ||
| 41 | my %_hStatus = ( | ||
| 42 | 1 => 'SERVICE_STOPPED', | ||
| 43 | 2 => 'SERVICE_START_PENDING', | ||
| 44 | 3 => 'SERVICE_STOP_PENDING', | ||
| 45 | 4 => 'SERVICE_RUNNING', | ||
| 46 | 5 => 'SERVICE_CONTINUE_PENDING', | ||
| 47 | 6 => 'SERVICE_PAUSE_PENDING', | ||
| 48 | 7 => 'SERVICE_PAUSED', | ||
| 49 | ); | ||
| 50 | return $_hStatus{$iSts} if(defined($iSts)); | ||
| 51 | |||
| 52 | my %hRes; | ||
| 53 | Win32::Service::GetStatus('', 'NeoServer', \%hRes); | ||
| 54 | return $_hStatus{$hRes{CurrentState}}; | ||
| 55 | } | ||
| 56 | 1; | ||
| 57 | __END__ |