From 12bf07a6ba03c358a8f087ecbcb0a5c090e8d711 Mon Sep 17 00:00:00 2001 From: NickHackman Date: Fri, 11 Feb 2022 13:59:24 -0600 Subject: [PATCH] service: systemd launch_only_once Set the type of service to oneshot if launch_only_once is provided; otherwise, simple. --- Library/Homebrew/service.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 5b4245cde5..2a870048ed 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -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?