Jasper in Console Applications Edit on GitHub


At this time, the Jasper team is focused on hosting applications either in IIS (or nginx) or as a console application that would be suitable for running in a Docker container. To that end, we've added the JasperAgent static class as a helper for quickly standing up Jasper applications in a console application.

The sample usage from the getting started topic would look like this:


using Jasper;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // This bootstraps and runs the Jasper
            // application as defined by MyAppRegistry
            // until the executable is stopped
            JasperAgent.Run<MyAppRegistry>();
        }
    }
}

At runtime, JasperAgent uses the JasperRegistry you hand it to bootstrap a JasperRuntime and run the application until the console process is stopped.

You can also use the command line arguments to customize how the application runs like this:


static void Main(string[] args)
{
    JasperAgent.Run<MyAppRegistry>(_ =>
    {
        if (args.Length == 1)
        {
            _.EnvironmentName = args[0];
        }
    });
}

Or like this:


static void Main(string[] args)
{
    // This gives you the ability to programmatically
    // construct the application based on the command line
    // arguments
    var registry = new JasperRegistry();


    JasperAgent.Run(registry);
}