╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
80 81 var tasks: std.Io.Group = .init; 82 defer tasks.cancel(io); 83 84 // run listeners 85 86 try err.print("serving HTTP on {s}, repo root {s}\n", .{ options.http_listen, repo_root_path }); 87 try err.flush(); 88 89 serve_http.runListener(repo_kind, any_repo_opts, io, allocator, repo_root_path, admin_repo_path, &http_server, &tasks, err); 90 91 try err.print("serving SSH on {s}\n", .{options.ssh_listen}); 92 try err.flush(); 93 94 const ssh_session_handler = serve_ssh.SessionHandler{ 95 .admin_repo_path = admin_repo_path, 96 .repo_root_path = repo_root_path, 97 .err = err, 98 }; 99 serve_ssh.runListener(io, allocator, &host_key, &ssh_session_handler, &ssh_server, &tasks, err); 100 101 try err.print("serving web UI on http://{s}/\n", .{options.wui_listen}); 102 try err.flush(); 103 104 web.run(io, allocator, &wui_server, &tasks, admin_repo_path, session_store, err); 105 106 if (@TypeOf(runnable) != void) { 107 try runnable.run(); 108 } else { 109 try tasks.await(io); 110 } 111 } 112 113 fn parseListenAddress(value: []const u8) !ListenAddress { 114 const colon = std.mem.lastIndexOfScalar(u8, value, ':') orelse return error.InvalidListenAddress; 115 if (colon == 0 or colon + 1 >= value.len) return error.InvalidListenAddress; 116 const port = try std.fmt.parseInt(u16, value[colon + 1 ..], 10); 117 return .{ .host = value[0..colon], .port = port }; 118 } 119