mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +03:00
Merge branch 'king-haskell' of github.com:urbit/urbit into king-boot-pb
This commit is contained in:
commit
0b667d8073
@ -103,6 +103,7 @@ import System.Environment (getProgName)
|
||||
import System.Posix.Signals (Handler(Catch), installHandler, sigTERM)
|
||||
import Text.Show.Pretty (pPrint)
|
||||
import Urbit.Time (Wen)
|
||||
import Vere.LockFile (lockFile)
|
||||
|
||||
import RIO.Directory
|
||||
|
||||
@ -196,22 +197,6 @@ tryPlayShip shipPath = do
|
||||
rio $ logTrace "SHIP RESUMED"
|
||||
Pier.pier shipPath Nothing sls
|
||||
|
||||
lockFile :: HasLogFunc e => FilePath -> RAcquire e ()
|
||||
lockFile pax = void $ mkRAcquire start stop
|
||||
where
|
||||
fil = pax <> "/.vere.lock"
|
||||
|
||||
stop handle = do
|
||||
logInfo $ display @Text $ ("Releasing lock file: " <> pack fil)
|
||||
io $ Lock.unlock fil handle
|
||||
|
||||
params = def { Lock.retryToAcquireLock = Lock.No }
|
||||
|
||||
start = do
|
||||
createDirectoryIfMissing True pax
|
||||
logInfo $ display @Text $ ("Taking lock file: " <> pack fil)
|
||||
io (Lock.lock params fil)
|
||||
|
||||
tryResume :: HasLogFunc e => FilePath -> RIO e ()
|
||||
tryResume shipPath = do
|
||||
rwith resumedPier $ \(serf, log, ss) -> do
|
||||
|
26
pkg/king/lib/Vere/LockFile.hs
Normal file
26
pkg/king/lib/Vere/LockFile.hs
Normal file
@ -0,0 +1,26 @@
|
||||
module Vere.LockFile (lockFile) where
|
||||
|
||||
import UrbitPrelude
|
||||
|
||||
import Data.Default (def)
|
||||
import RIO.Directory (createDirectoryIfMissing)
|
||||
import System.IO.LockFile.Internal (LockingParameters(..), RetryStrategy(..),
|
||||
lock, unlock)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
lockFile :: HasLogFunc e => FilePath -> RAcquire e ()
|
||||
lockFile pax = void $ mkRAcquire start stop
|
||||
where
|
||||
fil = pax <> "/.vere.lock"
|
||||
|
||||
stop handle = do
|
||||
logInfo $ display @Text $ ("Releasing lock file: " <> pack fil)
|
||||
io $ unlock fil handle
|
||||
|
||||
params = def { retryToAcquireLock = No }
|
||||
|
||||
start = do
|
||||
createDirectoryIfMissing True pax
|
||||
logInfo $ display @Text $ ("Taking lock file: " <> pack fil)
|
||||
io (lock params fil)
|
Loading…
Reference in New Issue
Block a user