Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/linux_admin/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ def run(cmd, options = {})
def run!(cmd, options = {})
AwesomeSpawn.run!(cmd, options)
end

# NOTE: only currently supports options: :params => []
def detach(cmd, options = {})
params = Array(options[:params])
Process.detach(Kernel.spawn(
"#{cmd} #{params.join(" ")}",
[:out, :err] => ["/dev/null", "w"]))
end
end
end
6 changes: 6 additions & 0 deletions lib/linux_admin/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def start
self
end

def start_and_detach
detach(cmd(:service),
:params => [id, "start"])
self
end

def stop
run!(cmd(:service),
:params => { nil => [id, "stop"] })
Expand Down