Skip to content

Commit

Permalink
Run exception handlers on SIGTERM in daml assistant (digital-asset#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocreature authored Jul 9, 2019
1 parent 13253d8 commit 75ea177
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
- DA.Sdk.Cli.System
- DA.Sdk.Cli.Version
- DAML.Assistant.Install.Path
- DamlHelper.Signals
- DA.Signals
- Development.IDE.Core.Compile
- Development.IDE.GHC.Compat
- {name: ImplicitParams, within: []}
Expand Down
3 changes: 1 addition & 2 deletions daml-assistant/daml-helper/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_library", "da_haskell_test")
load("//bazel_tools/packaging:packaging.bzl", "package_app")
load("@os_info//:os_info.bzl", "is_windows")

da_haskell_library(
name = "daml-helper-lib",
Expand All @@ -29,7 +28,7 @@ da_haskell_library(
"safe-exceptions",
"text",
"yaml",
] + ([] if is_windows else ["unix"]),
],
visibility = ["//visibility:public"],
deps = [
"//daml-assistant:daml-project-config",
Expand Down
2 changes: 1 addition & 1 deletion daml-assistant/daml-helper/src/DamlHelper/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import System.Environment
import System.Exit
import System.IO

import DA.Signals
import DamlHelper.Run
import DamlHelper.Signals

main :: IO ()
main =
Expand Down
2 changes: 2 additions & 0 deletions daml-assistant/exe/DAML/Assistant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module DAML.Assistant
( main
) where

import DA.Signals
import DAML.Project.Config
import DAML.Assistant.Types
import DAML.Assistant.Env
Expand All @@ -30,6 +31,7 @@ import Safe
-- | Run the assistant and exit.
main :: IO ()
main = displayErrors $ do
installSignalHandlers
builtinCommandM <- tryBuiltinCommand
case builtinCommandM of
Just builtinCommand -> do
Expand Down
2 changes: 1 addition & 1 deletion dev-env/bin/daml-sdk-head
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fi

cat > $DAML_HOME/bin/daml-head << EOF
#!/bin/bash
DAML_SDK_VERSION=0.0.0 $DAML_HEAD_SDK/daml/daml "\$@"
exec env DAML_SDK_VERSION=0.0.0 $DAML_HEAD_SDK/daml/daml "\$@"
EOF
chmod +x $DAML_HOME/bin/daml-head

Expand Down
3 changes: 2 additions & 1 deletion libs-haskell/da-hs-base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

load("//bazel_tools:haskell.bzl", "da_haskell_library", "da_haskell_test")
load("@os_info//:os_info.bzl", "is_windows")

da_haskell_library(
name = "da-hs-base",
Expand Down Expand Up @@ -50,7 +51,7 @@ da_haskell_library(
"utf8-string",
"uuid",
"vector",
],
] + ([] if is_windows else ["unix"]),
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{-# LANGUAGE CPP #-}

-- | Module that turns SIGTERM into a UserInterrupt exception in Unix.
module DamlHelper.Signals
module DA.Signals
( installSignalHandlers
) where

Expand All @@ -25,4 +25,3 @@ installSignalHandlers = do
mainThread <- myThreadId
void $ installHandler sigTERM (Catch $ throwTo mainThread UserInterrupt) Nothing
#endif

2 changes: 2 additions & 0 deletions unreleased.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ HEAD — ongoing

- [daml assistant] Fix VSCode path for use if not already in PATH on mac
- [DAML-LF] Fixed regression that produced an invalid daml-lf-archive artefact. See `#2058 <https://github.com/digital-asset/daml/issues/2058>`__.
- [daml assistant] Kill child processes on ``SIGTERM``. This means that killing
``daml sandbox`` will also kill the sandbox process.

0 comments on commit 75ea177

Please sign in to comment.