We work we have a number of windows services which each have a lot of stats they could expose. Currently they are only interrogatable by the logfiles and from any notifications we receive.
I have been toying with the idea of hosting a website in-process which would give a simple dashboard ui and access to a live view of the log file. The idea first struck me when I was experimenting with FubuMvc, as they have an
EmbeddedFubuMvcServer, which is very easy to use:
But while I like this, FubuMvc embedded seems like overkill.
Wouldn't it be nice if we could host an
expressjs app inside our process? They are very lightweight, and to get one setup is almost no coding (especially if you use the express commandline tool).
The Edge.js project provides an in-process bridge between the .net and nodejs worlds, and allows for communication between the two...
Create a new application (eg: ServiceWithEdge)
Create a subdirectory for the webui in your applications root (eg, next to the csproj file)
If you don't have express-generator installed, get it:
npm install -g express-generator
Cd to your webui directory, and create an express application:
express- there are some options if you want, see the guide
In visual studio, include the webui directory
- Mark all files as
copy if newer
- Mark all files as
Add a new js file in your webui root:
add the edgejs package:
PM> install-package edge.js
The following function will run the webui, and inject a callback for getting models from .net
- The last step to getting this to work is running
npm installin the webui directory of the build output folder. I use a rake file to build everything, so its just an extra task (see the entire Rakefile here):
ny route needing data from .net just needs to require the communicator file and call `getModel`:
All the code is available on github.
How I am aiming to use it
I am planning on constructing a nuget package to do all of this, so that all a developer needs to do is add the package, and configure which statistics they wish to show up on the web ui.