Restart the Suave application to save the file

I recently started with Suave; I am setting up a project using yoman and the F # generator. To run the application, I create an executable file using Fake, and then run it. Whenever I change application files, i.e. * .fs files, I have to repeat the process of creating and running the executable file.

Is there a better development method in which an application restores or reloads / reloads a file?

+5
source share
2 answers

The script construct for the F # Snippets project does just that.

The idea is that you have an app.fsx file that defines a top-level WebPart called app . You can see an example of F # Snippets here . The app.fsx script file can also load other files, so you can structure your application as you need.

build.fsx build script then starts the server, tracks the file system changes for your source code and app.fsx and reboots it with the F # Compiler Service in the background and replaces the “loaded” server with the one obtained from the new app value.

The only limitation of the current build of the script is that it does not correctly cancel the memory (probably this should be fixed by re-creating the F # Interactive Session in the build of the script), and therefore it runs out of memory after more reloads. Nevertheless, the workflow is much nicer!

+4
source

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() ) 
+1
source

Source: https://habr.com/ru/post/1247749/


All Articles