@@ -6,19 +6,19 @@ const default_port = 3000;
6
6
7
7
// always log .info, even in release modes
8
8
// change this to .debug if you want extreme debugging
9
- pub const std_options = struct {
10
- pub const log_level = .info ;
9
+ pub const std_options = std.Options {
10
+ . log_level = .info ,
11
11
};
12
12
13
13
pub fn usage () void {
14
14
std .debug .print ("USAGE: zig-zag-zoe [-p PORTNUMBER]\n " , .{});
15
- std .debug .print (" or use the PORT env var to set the port, for like Docker or whatever \n " , .{});
15
+ std .debug .print (" or use the PORT env var to set the port\n " , .{});
16
16
}
17
17
18
18
pub fn main () ! void {
19
19
var port : u16 = default_port ;
20
20
21
- const env_port = std .os .getenv ("PORT" );
21
+ const env_port = std .posix .getenv ("PORT" );
22
22
if (env_port != null and env_port .? .len > 0 ) {
23
23
port = try std .fmt .parseInt (u16 , env_port .? , 10 );
24
24
std .log .debug ("Port set to {} via ENV\n " , .{port });
@@ -60,31 +60,12 @@ pub fn main() !void {
60
60
const zero_wing : u8 = 0 ;
61
61
62
62
var game = try Game .init (grid_x , grid_y , players , win , zero_wing );
63
- try game .startWatcher ();
63
+ // try game.startWatcher();
64
64
65
- std .log .debug ("Setting pool size to {}" , .{Game .MAX_PLAYERS * 4 });
65
+ // std.log.debug("Setting pool size to {}", .{Game.MAX_PLAYERS * 4});
66
66
var server = try httpz .ServerCtx (* Game , * Game ).init (allocator , .{
67
67
.address = "0.0.0.0" ,
68
68
.port = port ,
69
- // .pool_size = Game.MAX_PLAYERS * 32, // allow up to 32 req/res pairs buffered for each player
70
- // .pool = .{
71
- // .min = Game.MAX_PLAYERS * 4,
72
- // .max = Game.MAX_PLAYERS * 24,
73
- // .timeout = 5000,
74
- // },
75
- // .thread_pool = Game.MAX_PLAYERS * 2,
76
- .request = .{
77
- .max_body_size = 256 ,
78
- .buffer_size = 1024 ,
79
- .max_header_count = 32 ,
80
- .max_param_count = 2 ,
81
- .max_query_count = 1 ,
82
- },
83
- .response = .{
84
- .body_buffer_size = 48_000 , // big enough for the biggest file
85
- .header_buffer_size = 256 ,
86
- .max_header_count = 8 ,
87
- },
88
69
}, & game );
89
70
server .notFound (notFound );
90
71
server .errorHandler (errorHandler );
@@ -103,7 +84,7 @@ pub fn main() !void {
103
84
// connect the game object to the router
104
85
game .addRoutes (router );
105
86
106
- const ru = std .os .getrusage (0 );
87
+ const ru = std .posix .getrusage (0 );
107
88
std .log .info ("[{}:{s}:{}:{}:{}] {s} {s}" , .{ std .time .timestamp (), @tagName (game .state ), 0 , ru .maxrss , ru .maxrss , "BOOT" , "Initial Startup" });
108
89
return server .listen ();
109
90
}
@@ -113,8 +94,8 @@ fn printValidAddresses(allocator: std.mem.Allocator, port: u16) !void {
113
94
114
95
// do some digging to get a list of IPv4 addresses that we are listening on
115
96
std .log .info ("- http://localhost:{}" , .{port });
116
- var hostBuffer : [std .os .HOST_NAME_MAX ]u8 = undefined ;
117
- const hostname = try std .os .gethostname (& hostBuffer );
97
+ var hostBuffer : [std .posix .HOST_NAME_MAX ]u8 = undefined ;
98
+ const hostname = try std .posix .gethostname (& hostBuffer );
118
99
std .log .info ("- http://{s}:{}" , .{ hostname , port });
119
100
120
101
var addressList = try std .net .getAddressList (allocator , hostname , port );
@@ -124,7 +105,7 @@ fn printValidAddresses(allocator: std.mem.Allocator, port: u16) !void {
124
105
defer uniqueIPv4Addresses .deinit ();
125
106
126
107
for (addressList .addrs ) | address | {
127
- if (address .any .family == std .os .AF .INET ) {
108
+ if (address .any .family == std .posix .AF .INET ) {
128
109
try uniqueIPv4Addresses .put (address .in , true );
129
110
}
130
111
}
0 commit comments