start-as-root option added in service spec files.
parent
ddeb253c1e
commit
2e66b44e58
|
@ -3,7 +3,7 @@ consumes: http?
|
|||
provides: www, http
|
||||
ports: http=80, https=443
|
||||
reload-command: kill -HUP ${SERVICE_PID}
|
||||
user: root
|
||||
start-as-root: true
|
||||
|
||||
%configuration nginx.conf
|
||||
|
||||
|
|
|
@ -347,7 +347,9 @@ class Service
|
|||
LibC.dup2 stdout_file.fd, 1
|
||||
LibC.dup2 stderr_file.fd, 2
|
||||
|
||||
System.become_user user_name
|
||||
unless @reference.start_as_root
|
||||
System.become_user user_name
|
||||
end
|
||||
|
||||
Process.exec command, args,
|
||||
chdir: (@reference.directory.try { |x| evaluate x } || root),
|
||||
|
|
|
@ -82,6 +82,7 @@ class ServiceDefinition
|
|||
getter directory : String?
|
||||
getter user : String?
|
||||
getter group : String?
|
||||
getter start_as_root : Bool?
|
||||
getter provides : String?
|
||||
getter consumes : Array(Consumes)
|
||||
getter environment_variables : Array(String)
|
||||
|
@ -103,6 +104,7 @@ class ServiceDefinition
|
|||
@directory = specs["directory"]?.try &.as_s
|
||||
@user = specs["user"]?.try &.as_s
|
||||
@group = specs["group"]?.try &.as_s
|
||||
@start_as_root = specs["start-as-root"]?.try(&.as_s).try(&.==("true")) || false
|
||||
@provides = specs["provides"]?.try &.as_a_or_s.map { |x| Provides.new x } || Array(Provides).new
|
||||
@consumes = specs["consumes"]?.try &.as_a_or_s.map { |x| Consumes.new x } || Array(Consumes).new
|
||||
@environment_variables = specs["environment-variables"]?.try &.as_a_or_s || Array(String).new
|
||||
|
|
Loading…
Reference in New Issue