fix(dev): raise macOS open-file limit before astro dev to prevent EMFILE
This commit is contained in:
@@ -7,6 +7,8 @@ foreground. One command replaces the two-terminal setup.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import platform
|
||||
import resource
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
@@ -233,6 +235,14 @@ def dev(
|
||||
"VITE_API_PORT": str(api_port), # picked up by astro.config.mjs
|
||||
}
|
||||
|
||||
# Astro's file watcher opens many handles; macOS defaults to 256, which
|
||||
# causes EMFILE. Raise the limit before forking so the child inherits it.
|
||||
if platform.system() == "Darwin":
|
||||
target = 65536
|
||||
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
if soft < target:
|
||||
resource.setrlimit(resource.RLIMIT_NOFILE, (min(target, hard), hard))
|
||||
|
||||
# Start astro dev in foreground (Ctrl+C stops everything)
|
||||
console.print(f"Starting [cyan]astro dev[/cyan] on port {port}…")
|
||||
console.print()
|
||||
|
||||
Reference in New Issue
Block a user