Last active
January 6, 2017 15:04
-
-
Save isaacabraham/601d058df22ac6c26c64 to your computer and use it in GitHub Desktop.
Hosting Suave in Azure Service Fabric
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Microsoft.ServiceFabric.Services | |
open Suave | |
open Suave.Http.Successful | |
open Suave.Web | |
open System.Fabric | |
open System.Threading | |
open System.Threading.Tasks | |
type SuaveService() = | |
inherit StatelessService() | |
override __.CreateCommunicationListener() = | |
{ new ICommunicationListener with | |
member __.Abort() = () | |
member __.CloseAsync _ = Task.FromResult() :> Task // should close down gracefully | |
member __.Initialize _ = () // any initialization goes here | |
member __.OpenAsync cancellationToken = | |
async { | |
let starting, server = startWebServerAsync defaultConfig (OK "Hello from Service Fabric!") | |
Async.Start(server, cancellationToken) | |
do! starting |> Async.Ignore | |
return (defaultConfig.bindings.Head.ToString()) | |
} |> Async.StartAsTask | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment