mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Move Sighandler to "serve" mode only
Currently the sighandler is setup regardless of the running mode, but it only does something in "serve" mode. In fetch mode, since there are no registered listeners, it intercepts the signal and does nothing. On MacOS at least, this isn't a great experience as it can leave the process running in the background.
This commit is contained in:
10
src/main.zig
10
src/main.zig
@@ -43,16 +43,13 @@ pub fn main() !void {
|
||||
const main_arena = main_arena_instance.allocator();
|
||||
defer main_arena_instance.deinit();
|
||||
|
||||
var sighandler = SigHandler{ .arena = main_arena };
|
||||
try sighandler.install();
|
||||
|
||||
run(gpa, main_arena, &sighandler) catch |err| {
|
||||
run(gpa, main_arena) catch |err| {
|
||||
log.fatal(.app, "exit", .{ .err = err });
|
||||
std.posix.exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
fn run(allocator: Allocator, main_arena: Allocator, sighandler: *SigHandler) !void {
|
||||
fn run(allocator: Allocator, main_arena: Allocator) !void {
|
||||
const args = try Config.parseArgs(main_arena);
|
||||
defer args.deinit(main_arena);
|
||||
|
||||
@@ -86,6 +83,9 @@ fn run(allocator: Allocator, main_arena: Allocator, sighandler: *SigHandler) !vo
|
||||
|
||||
switch (args.mode) {
|
||||
.serve => |opts| {
|
||||
var sighandler = SigHandler{ .arena = main_arena };
|
||||
try sighandler.install();
|
||||
|
||||
log.debug(.app, "startup", .{ .mode = "serve", .snapshot = app.snapshot.fromEmbedded() });
|
||||
const address = std.net.Address.parseIp(opts.host, opts.port) catch |err| {
|
||||
log.fatal(.app, "invalid server address", .{ .err = err, .host = opts.host, .port = opts.port });
|
||||
|
||||
Reference in New Issue
Block a user