Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

long running agents in f#

I use agents in different ways, one of which consists of 100 agents monitoring website changes, and reporting back to a supervisor which I can call to spawns new monitor off, or listen to the merged changes. This is only part of my program, and I am happy with it. I now would like to spin it off and that it runs truly independently of my main program.

(Yet I would like this independent spinoff to stay as much as possible inside the langage, and use the least amount of glue code possible)

What strategies do I have here / would you recommend ?

like image 614
nicolas Avatar asked Jan 17 '23 21:01

nicolas


1 Answers

One option for executing long-running agents is to write a Windows Service that starts with the operating system (possibly even before login) and runs in the background. Your main application can then connect to the service and communicate with it.

  • Here is a basic example of F# Windows Service on MSDN.

Running the agent in a service is quite easy. The communication between service and main application is more tricky, because they are two separate processes. The sample uses .NET Remoting, which has now been replaced with WCF, so I think that would be a thing to look at (especially if you want asynchronous communication). Alternatively, there are some F# projects that implement simple socket-based communication, which might be easier to use.

like image 57
Tomas Petricek Avatar answered Jan 24 '23 11:01

Tomas Petricek