misc, setup, util: Add a ulimit
I think this gives us the ability to open more files.
This commit is contained in:
@@ -8,6 +8,7 @@ Requires=systemd-networkd.service
|
||||
ExecStart=/usr/bin/mgmt run empty $OPTS
|
||||
RestartSec=5s
|
||||
Restart=always
|
||||
LimitNOFILE=16384
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -135,6 +135,7 @@ func (obj *Svc) Run(ctx context.Context) error {
|
||||
ExecStart: execStart,
|
||||
RestartSec: "5s",
|
||||
Restart: "always",
|
||||
LimitNOFILE: 16384,
|
||||
WantedBy: []string{"multi-user.target"},
|
||||
}
|
||||
unitData, err := unit.Template()
|
||||
|
||||
@@ -62,6 +62,9 @@ type UnitData struct {
|
||||
// Restart is the restart policy. Usually you want "always".
|
||||
Restart string
|
||||
|
||||
// LimitNOFILE is the max number of files this process can open.
|
||||
LimitNOFILE uint
|
||||
|
||||
// RemainAfterExit can be set to true to make it look like the service
|
||||
// is still active if it exits successfully.
|
||||
RemainAfterExit bool
|
||||
@@ -110,6 +113,9 @@ func (obj *UnitData) Template() (string, error) {
|
||||
if obj.Restart != "" {
|
||||
data += fmt.Sprintf("Restart=%s\n", obj.Restart)
|
||||
}
|
||||
if obj.LimitNOFILE > 0 {
|
||||
data += fmt.Sprintf("LimitNOFILE=%d\n", obj.LimitNOFILE)
|
||||
}
|
||||
|
||||
if obj.RemainAfterExit {
|
||||
data += "RemainAfterExit=yes\n"
|
||||
|
||||
Reference in New Issue
Block a user