I use a similar approach to Tomas, but I start the server in a child script build process. This causes a restart to restart a little slower, but not a memory or port leak. It also allows me to easily use a different working directory for my build scripts and application scripts (in this case. / App).
Here's a clipped version of my FAKE script.
#r "packages/FAKE/tools/FakeLib.dll" open Fake let wait() = System.Console.Read() |> ignore let runServer () = fireAndForget (fun startInfo -> startInfo.WorkingDirectory <- "./app" startInfo.FileName <- FSIHelper.fsiPath startInfo.Arguments <- "--define:RELOAD server.fsx") Target "Watch" (fun _ -> use watcher = !! "app/*.fsx" |> WatchChanges (fun changes -> tracefn "%A" changes killAllCreatedProcesses() runServer() ) runServer() wait() )
Eric source share