Forked from isaacabraham/suave-on-service-fabric.fs
Last active
August 29, 2015 14:27
-
-
Save TonyAbell/b1733ff2e4b09e39ae13 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 | |
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