Win32-services-wrapper 0.1.2.0 → 0.1.3.0
raw patch · 2 files changed
+24/−17 lines, 2 filesdep +Win32-errorsdep ~Win32-servicesdep ~basedep ~filepath
Dependencies added: Win32-errors
Dependency ranges changed: Win32-services, base, filepath
Files
Win32-services-wrapper.cabal view
@@ -1,5 +1,5 @@ name: Win32-services-wrapper-version: 0.1.2.0+version: 0.1.3.0 synopsis: Wrapper code for making a Win32 service description: Builds on the Win32-services package, providing a simple wrapper for turning a long-running process into a@@ -18,20 +18,22 @@ location: http://hub.darcs.net/ganesh/Win32-services-wrapper flag warn-as-error+ manual: True default: False description: Build with warnings-as-errors library- build-tools: ghc >= 7.4 && < 7.10+ build-tools: ghc >= 7.4 && < 7.12 hs-source-dirs: src exposed-modules: System.Win32.SystemServices.Wrapper other-modules: build-depends: - Win32-services >= 0.2.1 && < 0.3,+ Win32-services >= 0.3 && < 0.4, Win32 >= 2.2 && < 2.4,- filepath ==1.3.*,+ Win32-errors >= 0.2 && < 0.3,+ filepath > 1.3 && < 1.5, directory >= 1.1 && < 1.3,- base >= 4.5 && < 4.8+ base >= 4.5 && < 4.9 if flag(warn-as-error) ghc-options: -Werror
src/System/Win32/SystemServices/Wrapper.hs view
@@ -1,11 +1,16 @@-{-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables+{-# LANGUAGE CPP, ForeignFunctionInterface, ScopedTypeVariables #-} module System.Win32.SystemServices.Wrapper ( Service(..) , defineService ) where +-- The 'catch' function from Control.Exception was included in the Prelude+-- until version 4.6+#if MIN_VERSION_base(4,6,0)+#else import Prelude hiding ( catch )+#endif import Control.Concurrent ( MVar, newEmptyMVar, putMVar, takeMVar ) import Control.Exception ( catch, throwIO, SomeException )@@ -16,12 +21,12 @@ , openFile, IOMode(WriteMode) , Handle, hPutStrLn )-import System.Win32.SystemServices.Services- ( SERVICE_STATUS(..), SERVICE_STATE(..)- , SERVICE_CONTROL(..), SERVICE_ACCEPT(..), SERVICE_TYPE(..)+import System.Win32.Services+ ( ServiceStatus(..), ServiceState(..)+ , ServiceControl(..), ServiceAccept(..), ServiceType(..) , setServiceStatus, startServiceCtrlDispatcher- , nO_ERROR )+import System.Win32.Error ( ErrCode(..)) import System.Win32.Types ( HANDLE, DWORD ) data Service serviceState =@@ -31,20 +36,20 @@ , serviceStop :: serviceState -> IO () } -handler :: MVar () -> HANDLE -> SERVICE_CONTROL -> IO Bool-handler stopSignal hStatus STOP = do+handler :: MVar () -> HANDLE -> ServiceControl -> IO Bool+handler stopSignal hStatus Stop = do setServiceStatus hStatus stopPending putMVar stopSignal () return True-handler _ _ INTERROGATE = return True+handler _ _ Interrogate = return True handler _ _ _ = return False -running, stopPending, stopped :: SERVICE_STATUS-running = SERVICE_STATUS WIN32_OWN_PROCESS RUNNING [ACCEPT_STOP] nO_ERROR 0 0 0-stopPending = running { currentState = STOP_PENDING+running, stopPending, stopped :: ServiceStatus+running = ServiceStatus Win32OwnProcess Running [AcceptStop] Success 0 0 0+stopPending = running { currentState = StopPending , controlsAccepted = [] , waitHint = 3000 }-stopped = running { currentState = STOPPED+stopped = running { currentState = Stopped , controlsAccepted = [] , waitHint = 3000 }