mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +03:00
king: use c vere's heuristics for finding the serf binary
This commit is contained in:
parent
1953e4e2b3
commit
fc92fd3611
@ -63,12 +63,6 @@ Polish:
|
||||
changed too quickly.
|
||||
|
||||
|
||||
# Finding the Serf Executable
|
||||
|
||||
- [ ] Right now, `urbit-worker` is found by looking it up in the PATH. This
|
||||
is wrong, but what is right?
|
||||
|
||||
|
||||
# Take Advantage of New IPC Features
|
||||
|
||||
- [ ] Hook up `scry` to drivers.
|
||||
|
@ -14,7 +14,7 @@ import qualified Urbit.Vere.Serf as Serf
|
||||
data PierConfig = PierConfig
|
||||
{ _pcPierPath :: FilePath
|
||||
, _pcDryRun :: Bool
|
||||
, _pcSerfExe :: Text
|
||||
, _pcSerfExe :: Maybe Text
|
||||
, _pcSerfFlags :: [Serf.Flag]
|
||||
} deriving (Show)
|
||||
|
||||
|
@ -144,7 +144,7 @@ toPierConfig pierPath o@(CLI.Opts{..}) = PierConfig { .. }
|
||||
where
|
||||
_pcPierPath = pierPath
|
||||
_pcDryRun = oDryRun || isJust oDryFrom
|
||||
_pcSerfExe = fromMaybe "urbit-worker" oSerfExe
|
||||
_pcSerfExe = oSerfExe
|
||||
_pcSerfFlags = toSerfFlags o
|
||||
|
||||
toNetworkConfig :: CLI.Opts -> NetworkConfig
|
||||
|
@ -122,17 +122,24 @@ runSerf
|
||||
-> RAcquire e Serf
|
||||
runSerf vSlog pax = do
|
||||
env <- ask
|
||||
Serf.withSerf (config env)
|
||||
heuSerf <- heuristicallyFindSerf
|
||||
Serf.withSerf (config env heuSerf)
|
||||
where
|
||||
slog txt = atomically (readTVar vSlog) >>= (\f -> f txt)
|
||||
config env = Serf.Config
|
||||
{ scSerf = env ^. pierConfigL . pcSerfExe . to unpack
|
||||
config env heuSerf = Serf.Config
|
||||
{ scSerf = env ^. pierConfigL . pcSerfExe . to (unpack . fromMaybe heuSerf)
|
||||
, scPier = pax
|
||||
, scFlag = env ^. pierConfigL . pcSerfFlags
|
||||
, scSlog = \(pri, tank) -> printTank slog pri tank
|
||||
, scStdr = \txt -> slog (txt <> "\r\n")
|
||||
, scDead = pure () -- TODO: What can be done?
|
||||
}
|
||||
heuristicallyFindSerf = serfPrgm <$> listToMaybe <$> getArgs
|
||||
serfPrgm = \case
|
||||
Just (stripSuffix "urbit" -> Just pfix) -> pfix <> "urbit-worker"
|
||||
Just (stripSuffix "urbit-king" -> Just pfix) -> pfix <> "urbit-worker"
|
||||
_ -> "urbit-worker"
|
||||
|
||||
|
||||
|
||||
-- Boot a new ship. ------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user