sesh 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sesh/cli.rb +10 -10
- data/lib/sesh/logger.rb +2 -2
- data/lib/sesh/ssh_control.rb +2 -3
- data/lib/sesh/tmux_control.rb +8 -3
- data/lib/sesh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2379d1360354f9a664392fa0563f7f8c29e3cd3
|
4
|
+
data.tar.gz: 0e3f996071b819445f1c8f25681087cfc30cebf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14cee1076c7d257fc6eb7efbd940071f1201720b485f12b719f820a54181dcb0c3c7871198c68ed266803c9d989c5a6573e40be9284c08eaed5777e73161cd3a
|
7
|
+
data.tar.gz: 11aff5ce1e417617c4dd6d691e5a30e1a50c451d9c75418eb1d495c831ee696c26bcb911c0769f2218ea51efcfbbc5b3db0908f26737a9ff19e1139b8675445f
|
data/Gemfile.lock
CHANGED
data/lib/sesh/cli.rb
CHANGED
@@ -9,7 +9,7 @@ require 'deep_merge'
|
|
9
9
|
module Sesh
|
10
10
|
class Cli
|
11
11
|
def self.start
|
12
|
-
puts "Sesh v#{
|
12
|
+
puts; puts " Sesh v#{VERSION}".green; puts ' ==========='.green; puts
|
13
13
|
if ARGV.empty? or ARGV.include? '-h' or ARGV.include? '--help'
|
14
14
|
puts HELP_BANNER.blue; exit end
|
15
15
|
|
@@ -23,7 +23,7 @@ module Sesh
|
|
23
23
|
if @tmux_control.already_running?
|
24
24
|
Logger.fatal "Sesh project '#{@options[:project]}' is already running!"
|
25
25
|
else
|
26
|
-
Logger.
|
26
|
+
Logger.info "Starting Sesh project '#{@options[:project]}'..."
|
27
27
|
end
|
28
28
|
@tmux_control.kill_running_processes
|
29
29
|
if @tmux_control.issue_start_command! &&
|
@@ -31,20 +31,20 @@ module Sesh
|
|
31
31
|
sleep 1
|
32
32
|
if @tmux_control.already_running?
|
33
33
|
@tmux_control.store_pids_from_session!
|
34
|
-
Logger.
|
34
|
+
Logger.success 'Sesh started successfully.'
|
35
35
|
puts
|
36
36
|
else Logger.fatal 'Sesh failed to start!' end
|
37
37
|
else Logger.fatal 'Sesh failed to start after ten seconds!' end
|
38
38
|
when 'stop'
|
39
39
|
if @tmux_control.already_running?
|
40
|
-
Logger.
|
40
|
+
Logger.info "Stopping Sesh project '#{@options[:project]}'..."
|
41
41
|
else
|
42
42
|
Logger.fatal "Sesh project '#{@options[:project]}' is not running!"
|
43
43
|
end
|
44
44
|
@tmux_control.kill_running_processes
|
45
45
|
@tmux_control.issue_stop_command!
|
46
46
|
if $? && Logger.show_progress_until(-> { !@tmux_control.already_running? })
|
47
|
-
Logger.
|
47
|
+
Logger.success 'Sesh stopped successfully.'
|
48
48
|
puts
|
49
49
|
else
|
50
50
|
Logger.fatal 'Sesh failed to stop after ten seconds!'
|
@@ -83,8 +83,8 @@ module Sesh
|
|
83
83
|
running_projects = output.split("\n")
|
84
84
|
pcount = running_projects.count
|
85
85
|
if pcount > 0
|
86
|
-
Logger.
|
87
|
-
|
86
|
+
Logger.success "#{pcount} project#{pcount>1 ? 's':''} currently running:"
|
87
|
+
running_projects.each {|rp| Logger.info rp, 1 }
|
88
88
|
puts
|
89
89
|
else
|
90
90
|
Logger.fatal "There are no Sesh projects currently running."
|
@@ -99,13 +99,13 @@ module Sesh
|
|
99
99
|
when 'enslave'
|
100
100
|
Logger.fatal("Sesh project '#{@options[:project]}' is not running!") unless @tmux_control.already_running?
|
101
101
|
Logger.fatal("You must specify a machine to enslave! Eg: user@ip") if @options[:ssh][:remote_addr].nil?
|
102
|
-
Logger.
|
102
|
+
Logger.info "Attempting to connect #{@options[:ssh][:remote_addr]} to Sesh project '#{@options[:project]}'..."
|
103
103
|
if @ssh_control.enslave_peer!
|
104
|
-
Logger.
|
105
|
-
puts
|
104
|
+
Logger.success "Sesh client connected successfully."
|
106
105
|
else
|
107
106
|
Logger.fatal 'Sesh client failed to start.'
|
108
107
|
end
|
108
|
+
when 'begin' then @tmux_control.begin_tmuxinator_session!
|
109
109
|
when 'run'
|
110
110
|
unless ARGV.any?
|
111
111
|
Logger.fatal 'A second command is required!'
|
data/lib/sesh/logger.rb
CHANGED
@@ -4,8 +4,8 @@ require 'colorize'
|
|
4
4
|
module Sesh
|
5
5
|
class Logger
|
6
6
|
def self.debug(msg) $stderr.puts "> #{msg}" end
|
7
|
-
def self.fatal(msg)
|
8
|
-
$stderr.puts msg.red; $stderr.puts; exit 1 end
|
7
|
+
def self.fatal(msg, nest_level=0)
|
8
|
+
$stderr.puts "#{' ' * nest_level * 2}> #{msg}".red; $stderr.puts; exit 1 end
|
9
9
|
def self.warn(msg, nest_level=0)
|
10
10
|
$stderr.puts "#{' ' * nest_level * 2}> #{msg}".yellow end
|
11
11
|
def self.info(msg, nest_level=0)
|
data/lib/sesh/ssh_control.rb
CHANGED
@@ -36,10 +36,9 @@ module Sesh
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def enslave_peer!
|
39
|
-
|
40
|
-
ssh #{@options[:remote_addr]} "sesh connect #{@project} #{@options[:local_addr]}"
|
39
|
+
puts Sesh.format_and_run_command <<-BASH
|
40
|
+
ssh #{@options[:remote_addr]} -t "sesh connect #{@project} #{@options[:local_addr]}"
|
41
41
|
BASH
|
42
|
-
puts output
|
43
42
|
$?
|
44
43
|
end
|
45
44
|
end
|
data/lib/sesh/tmux_control.rb
CHANGED
@@ -16,10 +16,11 @@ module Sesh
|
|
16
16
|
|
17
17
|
def issue_start_command!
|
18
18
|
cmd = Sesh.format_command <<-BASH
|
19
|
-
tmux -S "#{@options[:socket_file]}" new-session -d "eval \$SHELL -l
|
19
|
+
tmux -S "#{@options[:socket_file]}" new-session -d "eval \\"\$SHELL -l -c 'rvm use default; bundle exec sesh begin'\\"" 2>&1
|
20
20
|
BASH
|
21
|
+
# puts cmd
|
21
22
|
output = `#{cmd}`.strip
|
22
|
-
return true if output.length == 0
|
23
|
+
return true if $? && output.length == 0
|
23
24
|
Logger.warn "Tmux failed to start with the following error: #{output}"; false
|
24
25
|
end
|
25
26
|
|
@@ -29,7 +30,8 @@ module Sesh
|
|
29
30
|
|
30
31
|
def obtain_pids_from_session
|
31
32
|
# TODO: grep this to just those pids from the current project
|
32
|
-
`tmux list-panes -s -F "\#{pane_pid} \#{pane_current_command}" | grep -v tmux | awk '{print $1}'`.strip.lines
|
33
|
+
`tmux -S "#{@options[:socket_file]}" list-panes -s -F "\#{pane_pid} \#{pane_current_command}" | grep -v tmux | awk '{print $1}'`.strip.lines
|
34
|
+
end
|
33
35
|
def store_pids_from_session!
|
34
36
|
File.open(@options[:pids_file], 'w') {|f|
|
35
37
|
obtain_pids_from_session.each{|pid| f.puts pid } }
|
@@ -43,6 +45,9 @@ module Sesh
|
|
43
45
|
end
|
44
46
|
def kill_process!(pid); `kill -9 #{pid}` end
|
45
47
|
|
48
|
+
def begin_tmuxinator_session!
|
49
|
+
%x[env TMUX='' mux start #{@project}] end
|
50
|
+
|
46
51
|
# Getter methods for passthru to SshControl class
|
47
52
|
def project; @project end
|
48
53
|
def options; @options end
|
data/lib/sesh/version.rb
CHANGED