MacOS Sierra上で、とあるテーマをHugoで動作させようとしたら、下記のエラーが出て起動しなかった
Error: listen tcp 127.0.0.1:1313: socket: too many open files
調べてみると、Macのulimitを変更する必要があるとの事で、「macOS Sierraでulimitを変更する方法 - Carpe Diem 」を参考にさせていただき、解決いたしました。
ulimit変更
# cat /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>524288</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
# cat /Library/LaunchDaemons/limit.maxproc.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
# chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
# chown root:wheel /Library/LaunchDaemons/limit.maxproc.plist
# chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist
# chmod 644 /Library/LaunchDaemons/limit.maxproc.plist
Mac再起動
変更確認
$ ulimit -a
Maximum size of core files created (kB, -c) 0
Maximum size of a process’s data segment (kB, -d) unlimited
Maximum size of files created by the shell (kB, -f) unlimited
Maximum size that may be locked into memory (kB, -l) unlimited
Maximum resident set size (kB, -m) unlimited
Maximum number of open file descriptors (-n) 524288
Maximum stack size (kB, -s) 8192
Maximum amount of cpu time in seconds (seconds, -t) unlimited
Maximum number of processes available to a single user (-u) 2048
Maximum amount of virtual memory available to the shell (kB, -v) unlimited