const std = @import("std"); const log = @import("logging.zig"); pub const event_persister = @import("services/event_persister.zig"); pub const event_broadcaster = @import("services/event_broadcaster.zig"); pub const scheduler = @import("services/scheduler.zig"); pub const lease_cleanup = @import("services/lease_cleanup.zig"); pub const late_runs = @import("services/late_runs.zig"); pub const automations = @import("services/automations.zig"); pub const Service = struct { name: []const u8, start: *const fn () anyerror!void, stop: *const fn () void, }; const all = [_]Service{ .{ .name = "event_persister", .start = event_persister.start, .stop = event_persister.stop }, .{ .name = "event_broadcaster", .start = event_broadcaster.start, .stop = event_broadcaster.stop }, .{ .name = "scheduler", .start = scheduler.start, .stop = scheduler.stop }, .{ .name = "lease_cleanup", .start = lease_cleanup.start, .stop = lease_cleanup.stop }, .{ .name = "late_runs", .start = late_runs.start, .stop = late_runs.stop }, .{ .name = "automations", .start = automations.start, .stop = automations.stop }, }; pub fn startAll() !void { for (all) |svc| { log.info("services", "starting {s}", .{svc.name}); try svc.start(); } } pub fn stopAll() void { // stop in reverse order var i = all.len; while (i > 0) { i -= 1; log.info("services", "stopping {s}", .{all[i].name}); all[i].stop(); } }