add shell
shell
This commit is contained in:
parent
805131c919
commit
80ee0ec3b1
5 changed files with 19 additions and 16 deletions
|
@ -84,7 +84,7 @@ let private parse now (db: Requirements) =
|
|||
else
|
||||
Ok (splitted.[0], splitted.[1]))
|
||||
|
||||
let executable = Which.which db.executable
|
||||
let executable = Shell.which db.executable
|
||||
let workdir = Path.of_string db.workdir |> Result.bind FileSystem.resolve
|
||||
|
||||
Result.zip when_ env
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
module Bidello.Jobs
|
||||
|
||||
open Bidello.Datatypes
|
||||
|
||||
open NodaTime
|
|
@ -70,7 +70,6 @@ type Bidello(client: IClusterClient) =
|
|||
let timeout = next_job_at - now |> _.TotalMilliseconds |> floor |> int32
|
||||
// printfn $"Waking up in: {timeout}|{next_job_at}"
|
||||
let! _wake_up = db |> Database.wait_notification timeout ct
|
||||
// TODO: se il lavoro da fare, è già in esecuzione (e ancora non terminato, che fare?)
|
||||
()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
module Bidello.Which
|
||||
module Bidello.Shell
|
||||
|
||||
open Sheller
|
||||
|
||||
open FSharp.Control.LazyExtensions
|
||||
|
||||
open Pentole.Path
|
||||
|
||||
let which (executable: string) =
|
||||
let private shell_ () =
|
||||
let possible_shells = [
|
||||
"/bin/sh"
|
||||
"/bin/bash"
|
||||
|
@ -15,12 +18,18 @@ let which (executable: string) =
|
|||
"/usr/bin/fish"
|
||||
]
|
||||
|
||||
let shell = List.tryFind (fun sh -> sh |> Path.of_string |> Result.isOk) possible_shells
|
||||
let error = Error "Can't find the system shell. Check your system $PATH."
|
||||
List.tryFind (fun sh -> sh |> Path.of_string |> Result.isOk) possible_shells
|
||||
|> Option.map Ok |> Option.defaultValue error
|
||||
|
||||
if shell |> Option.isSome then
|
||||
|
||||
let shell = Lazy.Create shell_
|
||||
|
||||
let which (executable: string) =
|
||||
let run (shell: string) =
|
||||
let rc =
|
||||
Builder
|
||||
.UseShell(shell.Value)
|
||||
.UseShell(shell)
|
||||
.UseExecutable("which")
|
||||
.WithArgument(executable)
|
||||
.UseNoThrow()
|
||||
|
@ -36,5 +45,6 @@ let which (executable: string) =
|
|||
else
|
||||
rc.StandardError
|
||||
|> Error
|
||||
else
|
||||
Error "Can't find the system shell. Check your system $PATH."
|
||||
|
||||
shell.Value
|
||||
|> Result.bind run
|
|
@ -13,13 +13,12 @@
|
|||
<Compile Include="Seq.fs" />
|
||||
<Compile Include="Result.fs" />
|
||||
<Compile Include="String.fs" />
|
||||
<Compile Include="Which.fs" />
|
||||
<Compile Include="Shell.fs" />
|
||||
<Compile Include="Datatypes.fs" />
|
||||
<Compile Include="Grains.fs" />
|
||||
<Compile Include="DatabaseMigrations.fs" />
|
||||
<Compile Include="Database.fs" />
|
||||
<Compile Include="Cron.fs" />
|
||||
<Compile Include="Jobs.fs" />
|
||||
<Compile Include="Library.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Loading…
Reference in a new issue