@@ -13,12 +13,12 @@ import (
1313 "sort"
1414 "strings"
1515
16- "pkg.re/essentialkaos/ek.v9 /errutil"
17- "pkg.re/essentialkaos/ek.v9 /fsutil"
18- "pkg.re/essentialkaos/ek.v9 /log"
19- "pkg.re/essentialkaos/ek.v9 /path"
20- "pkg.re/essentialkaos/ek.v9 /sliceutil"
21- "pkg.re/essentialkaos/ek.v9 /strutil"
16+ "pkg.re/essentialkaos/ek.v10 /errutil"
17+ "pkg.re/essentialkaos/ek.v10 /fsutil"
18+ "pkg.re/essentialkaos/ek.v10 /log"
19+ "pkg.re/essentialkaos/ek.v10 /path"
20+ "pkg.re/essentialkaos/ek.v10 /sliceutil"
21+ "pkg.re/essentialkaos/ek.v10 /strutil"
2222)
2323
2424// ////////////////////////////////////////////////////////////////////////////////// //
@@ -43,6 +43,7 @@ type Config struct {
4343 KillTimeout int // Global kill timeout in seconds
4444 LimitProc int // Global processes limit
4545 LimitFile int // Global descriptors limit
46+ LimitMemlock int // Global max locked memory limit
4647}
4748
4849type Service struct {
@@ -70,6 +71,7 @@ type ServiceOptions struct {
7071 IsRespawnEnabled bool // Respawn enabled flag
7172 LimitProc int // Processes limit
7273 LimitFile int // Descriptors limit
74+ LimitMemlock int // Max locked memory limit
7375 Resources * Resources // Resources limits (systemd only)
7476}
7577
@@ -291,57 +293,62 @@ func (s *Service) GetCommandExec(command string) string {
291293 return result
292294}
293295
294- // IsRespawnLimitSet return true if respawn options is set
296+ // IsRespawnLimitSet returns true if respawn options is set
295297func (so * ServiceOptions ) IsRespawnLimitSet () bool {
296298 return so .RespawnCount != 0 || so .RespawnInterval != 0
297299}
298300
299- // IsCustomLogEnabled return true if service have custom log
301+ // IsCustomLogEnabled returns true if service have custom log
300302func (so * ServiceOptions ) IsCustomLogEnabled () bool {
301303 return so .LogFile != ""
302304}
303305
304- // IsEnvSet return true if service have custom env vars
306+ // IsEnvSet returns true if service have custom env vars
305307func (so * ServiceOptions ) IsEnvSet () bool {
306308 return len (so .Env ) != 0
307309}
308310
309- // IsEnvFileSet return true if service have file with env vars
311+ // IsEnvFileSet returns true if service have file with env vars
310312func (so * ServiceOptions ) IsEnvFileSet () bool {
311313 return so .EnvFile != ""
312314}
313315
314- // IsFileLimitSet return true if descriptors limit is set
316+ // IsFileLimitSet returns true if descriptors limit is set
315317func (so * ServiceOptions ) IsFileLimitSet () bool {
316318 return so .LimitFile != 0
317319}
318320
319- // IsProcLimitSet return true if processes limit is set
321+ // IsProcLimitSet returns true if processes limit is set
320322func (so * ServiceOptions ) IsProcLimitSet () bool {
321323 return so .LimitProc != 0
322324}
323325
324- // IsKillSignalSet return true if custom kill signal set
326+ // IsMemlockLimitSet returns true if max memory limit is set
327+ func (so * ServiceOptions ) IsMemlockLimitSet () bool {
328+ return so .LimitMemlock != 0
329+ }
330+
331+ // IsKillSignalSet returns true if custom kill signal set
325332func (so * ServiceOptions ) IsKillSignalSet () bool {
326333 return so .KillSignal != ""
327334}
328335
329- // IsKillModeSet return true if custom kill mode set
336+ // IsKillModeSet returns true if custom kill mode set
330337func (so * ServiceOptions ) IsKillModeSet () bool {
331338 return so .KillMode != ""
332339}
333340
334- // IsReloadSignalSet return true if custom reload signal set
341+ // IsReloadSignalSet returns true if custom reload signal set
335342func (so * ServiceOptions ) IsReloadSignalSet () bool {
336343 return so .ReloadSignal != ""
337344}
338345
339- // IsResourcesSet return true if resources limits are set
346+ // IsResourcesSet returns true if resources limits are set
340347func (so * ServiceOptions ) IsResourcesSet () bool {
341348 return so .Resources != nil
342349}
343350
344- // EnvString return environment variables as string
351+ // EnvString returns environment variables as string
345352func (so * ServiceOptions ) EnvString () string {
346353 if len (so .Env ) == 0 {
347354 return ""
@@ -491,6 +498,14 @@ func mergeServiceOptions(dst, src *ServiceOptions) {
491498 if dst .LimitProc == 0 {
492499 dst .LimitProc = src .LimitProc
493500 }
501+
502+ if dst .LimitProc == 0 {
503+ dst .LimitProc = src .LimitProc
504+ }
505+
506+ if dst .LimitMemlock == 0 {
507+ dst .LimitMemlock = src .LimitMemlock
508+ }
494509}
495510
496511// configureDefaults set options default values
0 commit comments