Skip to content

Instantly share code, notes, and snippets.

@granicz
Created September 3, 2015 16:01
Show Gist options
  • Save granicz/8794dec65216087d14bd to your computer and use it in GitHub Desktop.
Save granicz/8794dec65216087d14bd to your computer and use it in GitHub Desktop.
Running WebSharper on Suave
module SelfHostedServer =
open global.Owin
open System.Net
open Suave
open Suave.Types
open Suave.Http.Successful
open Suave.Web
open Suave.Owin
open WebSharper.Owin
[<EntryPoint>]
let Main = function
| [| rootDirectory |] ->
let app =
SiteletMiddleware<_>.AsMidFunc(Options.Create(rootDirectory), Site.Main)
|> Suave.Owin.OwinApp.ofMidFunc
startWebServer defaultConfig app
0
| _ ->
eprintfn "Usage: Application1 ROOT_DIRECTORY"
1
System.InvalidCastException: Unable to cast object of type 'Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.Object]' to type 'System.String'.
at Microsoft.Owin.OwinRequest.Get[T](String key)
at Microsoft.Owin.OwinRequest.get_Host()
at Microsoft.Owin.OwinRequest.get_Uri()
at WebSharper.Owin.Internal.O2W.Request(IOwinRequest req)
at WebSharper.Owin.Internal.dispatch[T](ContextBuilder cb, Sitelet`1 s, IOwinContext context)
[I] 2015-09-03T15:59:02.4169399Z: listener started in 15.625 ms with binding 127.0.0.1:8083 [Suave.Tcp.tcpIpServer]
@haf
Copy link

haf commented Sep 12, 2015

Resolved pending breakpoint at 'Logger.fs:17,1' to void Suave.Logging.Loggers.CombiningLogger.Suave-Logging-Logger-Log (Suave.Logging.LogLevel level, Microsoft.FSharp.Core.FSharpFunc<Microsoft.FSharp.Core.Unit,Suave.Logging.LogLine> fLine) [0x00000].
Resolved pending breakpoint at 'LogLine.fs:26,1' to Suave.Logging.LogLine Suave.Logging.LogLineModule.mk (string path, Suave.Logging.LogLevel level, Suave.Logging.TraceHeader trace, Microsoft.FSharp.Core.FSharpOption<System.Exception> ex, string message) [0x00000].
[V] 2015-09-12T16:36:55.2530640Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[V] 2015-09-12T16:36:57.6246410Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
[I] 2015-09-12T16:36:57.7016430Z: listener started in 12101.179 ms with binding 127.0.0.1:8083 [Suave.Tcp.tcpIpServer]
[I] 2015-09-12T16:36:57.7017040Z: listener started in 12101.179 ms with binding 127.0.0.1:8083 [Suave.Tcp.tcpIpServer]
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
[V] 2015-09-12T16:37:05.7613750Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.tcpIpServer.job]
[V] 2015-09-12T16:37:05.7614160Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.tcpIpServer.job]
[V] 2015-09-12T16:37:05.7662240Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.tcpIpServer.job] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.7662630Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.tcpIpServer.job] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.7709390Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2015-09-12T16:37:05.7709670Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2015-09-12T16:37:05.7720590Z: reading first line of request [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.7720840Z: reading first line of request [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.7878890Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.7879470Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.8029750Z: reading headers [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.8030500Z: reading headers [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.8103320Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.8103710Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2015-09-12T16:37:05.8268440Z: parsing post data [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.8268920Z: parsing post data [Suave.Web.processRequest]
[V] 2015-09-12T16:37:05.8294600Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2015-09-12T16:37:05.8295350Z: <- processor [Suave.Web.httpLoop.loop]
Resolved pending breakpoint at 'Owin.fs:592,1' to Microsoft.FSharp.Control.FSharpAsync<Microsoft.FSharp.Core.FSharpChoice<Microsoft.FSharp.Core.Unit,Suave.Sockets.Error>> [email protected] (Microsoft.FSharp.Core.Unit unitVar) [0x00000].
[V] 2015-09-12T16:37:12.0537040Z: Yielding to OWIN middleware [Suave.Owin]
[V] 2015-09-12T16:37:12.0537680Z: Yielding to OWIN middleware [Suave.Owin]

HUNG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment