mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
--dump-limits flag to inspect what the max file descriptor & stack size is
This commit is contained in:
@@ -77,6 +77,8 @@ fn addInternalPackages(step: *std.build.LibExeObjStep, allocator: *std.mem.Alloc
|
||||
.path = pkgPath("src/http/network_thread.zig"),
|
||||
};
|
||||
|
||||
thread_pool.dependencies = &.{ io, http };
|
||||
|
||||
network_thread.dependencies = &.{
|
||||
io,
|
||||
thread_pool,
|
||||
|
||||
@@ -430,6 +430,7 @@ pub const Bundler = struct {
|
||||
},
|
||||
};
|
||||
Output.flush();
|
||||
var writer = Output.writer();
|
||||
std.json.stringify(bundler.env.map.*, opts, Output.writer()) catch unreachable;
|
||||
Output.flush();
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ pub const Arguments = struct {
|
||||
|
||||
const debug_params = [_]ParamType{
|
||||
clap.parseParam("--dump-environment-variables Dump environment variables from .env and process as JSON and quit. Useful for debugging") catch unreachable,
|
||||
clap.parseParam("--dump-limits Dump system limits. Useful for debugging") catch unreachable,
|
||||
clap.parseParam("--disable-bun.js Disable Bun.js from loading in the dev server") catch unreachable,
|
||||
};
|
||||
|
||||
@@ -245,6 +246,7 @@ pub const Arguments = struct {
|
||||
|
||||
ctx.debug.dump_environment_variables = args.flag("--dump-environment-variables");
|
||||
ctx.debug.fallback_only = args.flag("--disable-bun.js");
|
||||
ctx.debug.dump_limits = args.flag("--dump-limits");
|
||||
|
||||
// var output_dir = args.option("--outdir");
|
||||
var output_dir: ?string = null;
|
||||
@@ -565,6 +567,7 @@ pub const PrintBundleCommand = struct {
|
||||
pub const Command = struct {
|
||||
pub const DebugOptions = struct {
|
||||
dump_environment_variables: bool = false,
|
||||
dump_limits: bool = false,
|
||||
fallback_only: bool = false,
|
||||
silent: bool = false,
|
||||
};
|
||||
|
||||
@@ -114,6 +114,12 @@ pub const BunCommand = struct {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.debug.dump_limits) {
|
||||
fs.FileSystem.printLimits();
|
||||
std.os.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
var generated_server = false;
|
||||
if (this_bundler.options.framework) |*framework| {
|
||||
if (framework.toAPI(allocator, this_bundler.fs.top_level_dir) catch null) |_server_conf| {
|
||||
|
||||
18
src/fs.zig
18
src/fs.zig
@@ -480,6 +480,24 @@ pub const FileSystem = struct {
|
||||
return try allocator.dupe(u8, joined);
|
||||
}
|
||||
|
||||
pub fn printLimits() void {
|
||||
const LIMITS = [_]std.os.rlimit_resource{ std.os.rlimit_resource.STACK, std.os.rlimit_resource.NOFILE };
|
||||
Output.print("{{\n", .{});
|
||||
|
||||
inline for (LIMITS) |limit_type, i| {
|
||||
const limit = std.os.getrlimit(limit_type) catch return;
|
||||
|
||||
if (i == 0) {
|
||||
Output.print(" \"stack\": [{d}, {d}],\n", .{ limit.cur, limit.max });
|
||||
} else if (i == 1) {
|
||||
Output.print(" \"files\": [{d}, {d}]\n", .{ limit.cur, limit.max });
|
||||
}
|
||||
}
|
||||
|
||||
Output.print("}}\n", .{});
|
||||
Output.flush();
|
||||
}
|
||||
|
||||
pub const RealFS = struct {
|
||||
entries_mutex: Mutex = Mutex.init(),
|
||||
entries: *EntriesOption.Map,
|
||||
|
||||
@@ -1159,7 +1159,7 @@ pub const RequestContext = struct {
|
||||
handler.handleJSError(.configure_defines, err) catch {};
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
var entry_point = boot;
|
||||
if (!std.fs.path.isAbsolute(entry_point)) {
|
||||
const resolved_entry_point = vm.bundler.resolver.resolve(
|
||||
@@ -3056,6 +3056,12 @@ pub const Server = struct {
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug.dump_limits) {
|
||||
Fs.FileSystem.printLimits();
|
||||
std.os.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug.fallback_only or server.bundler.env.map.get("BUN_DISABLE_BUN_JS") != null) {
|
||||
RequestContext.fallback_only = true;
|
||||
RequestContext.JavaScriptHandler.javascript_disabled = true;
|
||||
|
||||
Reference in New Issue
Block a user