packages feed

sensu-run 0.6.1.1 → 0.7.0

raw patch · 4 files changed

+45/−9 lines, 4 filesdep ~basedep ~process

Dependency ranges changed: base, process

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for sensu-run +## 0.7.0 -- 2019-06-17++* Handle signals and resend them to the monitored process (#27)+ ## 0.6.1.1 -- 2019-05-28  * Relax upper version bounds for http-client and network
README.md view
@@ -1,8 +1,6 @@ # sensu-run [![Hackage](https://img.shields.io/hackage/v/sensu-run.svg)](http://hackage.haskell.org/package/sensu-run) [![Hackage-Deps](https://img.shields.io/hackage-deps/v/sensu-run.svg)](http://packdeps.haskellers.com/feed?needle=sensu-run)-[![Stackage LTS](http://stackage.org/package/sensu-run/badge/lts)](http://stackage.org/lts/package/sensu-run)-[![Stackage Nightly](http://stackage.org/package/sensu-run/badge/nightly)](http://stackage.org/nightly/package/sensu-run) [![Build Status](https://travis-ci.org/maoe/sensu-run.svg?branch=master)](https://travis-ci.org/maoe/sensu-run) [![Build status](https://ci.appveyor.com/api/projects/status/k9594kkn4tncotqt/branch/master?svg=true)](https://ci.appveyor.com/project/maoe/sensu-run/branch/master) @@ -30,8 +28,8 @@ % sensu-run --help Usage: sensu-run ([-n|--name NAME] [--source SOURCE] [--ttl SECONDS]                  [--timeout SECONDS] [--handler HANDLER] ([--port PORT] |-                 [--server URL]) [--redirect] [--dry|--dry-run] [-s|--shell]-                 [COMMAND] | [-v|--version])+                 [--server URL]) [--redirect] [--no-lock] [--dry|--dry-run]+                 [-s|--shell] [COMMAND] | [-v|--version])  Available options:   -h,--help                Show this help text@@ -47,6 +45,8 @@                            the specified port (default: 3030)   --server URL             Send results to the specified Sensu server   --redirect               Redirect command output to sensu-run's output+  --no-lock                Do not create a lock file to allow multiple instances+                           to run   --dry,--dry-run          Dump the JSON object which is supposed to be sent   -s,--shell               Execute the command using the shell ```@@ -105,3 +105,12 @@ ```sh sensu-run --name check-true --handler foo --server sensu1.example.com --server sensu2.example.com --dry-run -- du -s $HOME/src ```++## Handling signals on UNIX systems++`sensu-run` traps the following signals and resends them to the monitored process:++* SIGHUP+* SIGINT+* SIGQUIT+* SIGTERM
sensu-run.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: sensu-run-version: 0.6.1.1+version: 0.7.0 synopsis: A tool to send command execution results to Sensu description:   @sensu-run@ is a command line tool to send command execution results to Sensu@@ -18,8 +18,6 @@   CHANGELOG.md   README.md tested-with:-  GHC == 8.0.2-  GHC == 8.2.2   GHC == 8.4.4   GHC == 8.6.5   GHC == 8.8.1@@ -29,7 +27,7 @@   build-depends:     , aeson >= 0.11 && < 1.5     , async < 2.3-    , base >= 4.9 && < 4.13+    , base >= 4.11 && < 4.13     , bytestring >= 0.10 && < 0.11     , directory < 1.4     , filelock < 0.2@@ -40,7 +38,7 @@     , lens >= 4.15 && < 4.18     , network >= 2.2.3 && < 3.2     , optparse-applicative >= 0.12 && < 0.15-    , process >= 1.4 && < 1.7+    , process >= 1.6.3.0 && < 1.7     , temporary >= 1.1 && < 1.4     , text >= 1.2.2 && < 1.3     , time >= 1.5.0.1 && < 1.10
sensu-run.hs view
@@ -21,6 +21,7 @@ import Data.Monoid import System.Exit import System.IO+import Text.Printf (hPrintf) import qualified Data.List.NonEmpty as NE import qualified Data.Version as V import qualified System.Timeout as Timeout@@ -61,6 +62,8 @@   hiding (Options) #endif +import System.Posix.Signals+ main :: IO () main = do   issued <- getCurrentTime@@ -208,6 +211,7 @@     , use_process_jobs = True #endif     }+  getPid ph >>= traverse_ installSignalHandlers   return (out, err, ph)  redirectOutput :: Handle -> [Handle] -> IO ()@@ -384,3 +388,24 @@ showCmdSpec = \case   ShellCommand cmd -> cmd   RawCommand cmd args -> unwords $ cmd:args++-- | List of signals to trap+signalsToTrap :: [Signal]+signalsToTrap =+  [ sigHUP+  , sigINT+  , sigQUIT+  , sigTERM+  ]++installSignalHandlers :: Pid -> IO ()+installSignalHandlers pid =+  for_ signalsToTrap $ \sig ->+    installHandler sig (handler sig) (Just reservedSignals)+  where+    handler sig = CatchOnce $ do+      hPrintf stderr+        "sensu-run caught signal %s. Resending the signal to PID %s.\n"+        (show sig)+        (show pid)+      signalProcess sig pid