Skip to content

Hosting your wisp

A wisp you run for real keeps its id and secret out of its code, keeps its place across restarts, stops cleanly when you deploy, and starts again on its own if it ever stops. A wisp in many servers runs one process for each slice (Many servers).

On your own machine, in user secrets:

Terminal window
dotnet user-secrets set Wisp:Id <id>
dotnet user-secrets set Wisp:Secret <secret>

A host reads user secrets only in the Development environment, which dotnet run uses in a project made with dotnet new worker. A console project needs dotnet add package Microsoft.Extensions.Hosting, using Microsoft.Extensions.Hosting;, dotnet user-secrets init, and DOTNET_ENVIRONMENT=Development when you run it.

On a server, in the environment: Wisp__Id and Wisp__Secret.

Start from the worker template and add the hosting package:

Terminal window
dotnet new worker -n Lucky
cd Lucky
dotnet add package Woosh.Wisp.Hosting
using Woosh.Wisp;
var builder = Host.CreateApplicationBuilder(args);
var games = builder.Configuration.GetConnectionString("Game");
builder.Services.AddDbContext<GameDb>(o => o.UseNpgsql(games));
builder.Services
.AddWisp(o => o with
{
Activity = "Dealing blackjack",
CursorFile = "wisp-cursor.json",
})
.AddCommands<Gifts>()
.Configure((wisp, services) => wisp.When<ServerJoined>()
.Do(e => Console.WriteLine($"Added to {e.Name}")));
await builder.Build().RunAsync();

What the host does:

  • The connection follows the host. It opens when the host starts and closes cleanly when it stops, with your wisp’s place kept (Running well). A wrong or reset secret stops the host.
  • Each run, press and form sending gets an instance of its own, made in a scope of the host’s services and disposed when it is done. A class of commands can take a database context, or any scoped service, through its constructor. Register the class as a singleton yourself to share one.
  • WispClient is a service. Inject it anywhere to post, such as from a timer that announces a draw. An ICursorStore you register is used for your wisp’s place.

Configuration:

Key
Wisp:Id, Wisp:Secret who your wisp is, from developer.woosh.no
Wisp:Activity its own words
Wisp:CursorFile where it keeps its place between restarts
Wisp:Slice which slice this process runs, for a wisp in many servers (Many servers)

WISP_ID and WISP_SECRET work too, as they do without a host. Run the host as a service, or in a container, so it starts again if it stops.

How to keep a wisp quick, keep its place and deploy without a gap is on Running well.

© 2026 Woosh AS. All rights reserved.