From b490efdc0a147e8f14e1326e5437f13c0946e5a9 Mon Sep 17 00:00:00 2001 From: Daniel Sandbecker Date: Wed, 27 Aug 2014 11:17:59 +0200 Subject: [PATCH 1/3] Don't start again if running --- bin/runnel | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/runnel b/bin/runnel index e33201b..a650153 100755 --- a/bin/runnel +++ b/bin/runnel @@ -110,10 +110,15 @@ class Runnel end def start - puts "Starting #{conf[:name]}" - puts "AUTOSSH_PIDFILE=#{pid_file} autossh -M #{conf[:mport]} #{conf[:command]}" - ENV['AUTOSSH_PIDFILE'] = pid_file - `autossh -M #{conf[:mport]} #{conf[:command]}` + if running? + puts "It seems like #{conf[:name]} is already running:" + puts pp_description + else + puts "Starting #{conf[:name]}" + puts "AUTOSSH_PIDFILE=#{pid_file} autossh -M #{conf[:mport]} #{conf[:command]}" + ENV['AUTOSSH_PIDFILE'] = pid_file + `autossh -M #{conf[:mport]} #{conf[:command]}` + end end def kill From b1b23b592e6af81d750290c694b58909eea4a89c Mon Sep 17 00:00:00 2001 From: Daniel Sandbecker Date: Mon, 4 Sep 2017 11:45:40 +0200 Subject: [PATCH 2/3] Add restart command --- bin/runnel | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/runnel b/bin/runnel index a650153..5000152 100755 --- a/bin/runnel +++ b/bin/runnel @@ -174,6 +174,14 @@ else else Runnel.start_all end + when "restart" + if ARGV[1] + Runnel.kill(ARGV[1]) + Runnel.start(ARGV[1]) + else + Runnel.kill_all + Runnel.start_all + end when "help" puts HELP else From 98dc362181828ff482f184e57ee6cac248eca3f0 Mon Sep 17 00:00:00 2001 From: Daniel Sandbecker Date: Mon, 4 Sep 2017 11:46:25 +0200 Subject: [PATCH 3/3] Use warn instead of puts for warnings ... --- bin/runnel | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/runnel b/bin/runnel index 5000152..1327476 100755 --- a/bin/runnel +++ b/bin/runnel @@ -111,8 +111,8 @@ class Runnel def start if running? - puts "It seems like #{conf[:name]} is already running:" - puts pp_description + warn "It seems like #{conf[:name]} is already running:" + warn pp_description else puts "Starting #{conf[:name]}" puts "AUTOSSH_PIDFILE=#{pid_file} autossh -M #{conf[:mport]} #{conf[:command]}" @@ -125,7 +125,7 @@ class Runnel if running? `kill #{pid}` else - puts "Unable to find a running #{conf[:name]}" + warn "Unable to find a running #{conf[:name]}" end end