service: systemd launch_only_once

Set the type of service to oneshot if launch_only_once is provided; otherwise, simple.
This commit is contained in:
NickHackman 2022-02-11 13:59:24 -06:00 committed by Nick Hackman
parent 9f4949c8c6
commit 12bf07a6ba

View File

@ -334,11 +334,14 @@ module Homebrew
WantedBy=multi-user.target
[Service]
Type=simple
ExecStart=#{command.join(" ")}
EOS
# command needs to be first because it initializes all other values
cmd = command.join(" ")
options = []
options << "Type=#{@launch_only_once == true ? "oneshot" : "simple"}"
options << "ExecStart=#{cmd}"
options << "Restart=always" if @keep_alive == true
options << "RestartSec=#{restart_delay}" if @restart_delay.present?
options << "WorkingDirectory=#{@working_dir}" if @working_dir.present?