Skip to content

Instantly share code, notes, and snippets.

@TonyAbell
Forked from isaacabraham/suave-on-service-fabric.fs
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyAbell/b1733ff2e4b09e39ae13 to your computer and use it in GitHub Desktop.
Save TonyAbell/b1733ff2e4b09e39ae13 to your computer and use it in GitHub Desktop.
Hosting Suave in Azure Service Fabric
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
member __.Initialize _ = ()
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
}
[<EntryPoint>]
let main argv =
use fabricRuntime = FabricRuntime.Create()
fabricRuntime.RegisterServiceType("SuaveApiType", typeof<SuaveService>)
Thread.Sleep(Timeout.Infinite)
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment