Skip to content
Snippets Groups Projects
Commit 265c7ae3 authored by Mr. Snow Ball / projects's avatar Mr. Snow Ball / projects :arrows_counterclockwise:
Browse files

Restart failed script on click

parent 8b4abaac
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ import QBar.TagParser ...@@ -7,6 +7,7 @@ import QBar.TagParser
import QBar.Time import QBar.Time
import Control.Exception (IOException) import Control.Exception (IOException)
import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)
import Data.Aeson (encode) import Data.Aeson (encode)
import qualified Data.ByteString.Lazy.Char8 as C8 import qualified Data.ByteString.Lazy.Char8 as C8
import qualified Data.Text.Lazy as T import qualified Data.Text.Lazy as T
...@@ -44,7 +45,12 @@ scriptBlock clickEvents path = catchP startScriptProcess (handleError Nothing) ...@@ -44,7 +45,12 @@ scriptBlock clickEvents path = catchP startScriptProcess (handleError Nothing)
where where
handleError :: Maybe ExitCode -> IOException -> Block handleError :: Maybe ExitCode -> IOException -> Block
handleError exitCode exc = case result of handleError exitCode exc = case result of
Left msg -> forever $ pushBlockUpdate $ mkErrorOutput msg Left msg -> do
signal <- liftIO newEmptyMVar
pushBlockUpdate' (const $ liftIO $ putMVar signal ()) $
mkErrorOutput msg
liftIO $ takeMVar signal
startScriptProcess
Right x -> x Right x -> x
where where
result = case (isEOFError exc, exitCode) of result = case (isEOFError exc, exitCode) of
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment