capistrano-procsd 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3750ba4bc43d0a0bbb89551c6fe7b8a7aed6256d0ee80eff0d30da7b104fb814
4
- data.tar.gz: 50eb8cada745c68fe0f4c3f795f85228831a413a5c87ffa666efaade8541a540
3
+ metadata.gz: 678f36b61233ee76105780721fa080ebb1408fea53b2721cf1af759f7506e6b0
4
+ data.tar.gz: 45f9889af566c91b88f864d8cb1619b2298311e986c6421ffc45c27108b6b357
5
5
  SHA512:
6
- metadata.gz: ae68476dbfd4e433134b0c39907c6b4ccf5aad6599f80985af3faca56a76cf3422423e39679107dba7301ea1e2b285f11df980cd37fb555f30091573097514b8
7
- data.tar.gz: aad52774d9cd39733df3fd11779b90bc44b7948420c2f0c01d861d67050198dab0bb73198ab2b115a8925f386d4a296e6b381768afe611a05401affb91a5cbf7
6
+ metadata.gz: c953b465c7e78772927a04e2c559e28fca5feb40a3cd3e18b71746c3c1359560abc4ed8b8b0010544f9b58adb810ed727051ed2be582df8588556fede6d98a36
7
+ data.tar.gz: dcdc13860d1c7c224c154084549012c92f97b4a5511a03179b6c3da6c303183f719dda8dd6242430e180fae44c5c46d46297c29187bb6861377150d168a889e9
data/README.md CHANGED
@@ -23,7 +23,7 @@ Add to your application `Gemfile` somewhere:
23
23
  # Gemfile
24
24
 
25
25
  group :development do
26
- gem 'capistrano-procsd' require: false
26
+ gem 'capistrano-procsd', require: false
27
27
  end
28
28
  ```
29
29
 
@@ -45,9 +45,10 @@ after "deploy:publishing", "procsd:create_or_restart"
45
45
 
46
46
  Done!
47
47
 
48
- ### Note about procsd location on the remote server
48
+ ### Procsd location on the remote server
49
+ #### System-wide
49
50
 
50
- Configuration above assumes that you have `$ procsd` executable somewhere in the system path on your remote server. You can install gem system-wide this way:
51
+ Configuration above assumes that you have `$ procsd` executable somewhere in the global system path on your remote server. You can install gem system-wide this way:
51
52
 
52
53
  ```bash
53
54
  # Install ruby system-wide from apt repositories:
@@ -55,9 +56,16 @@ $ sudo apt install ruby
55
56
 
56
57
  # Install procsd gem system-wide:
57
58
  $ sudo gem install procsd
59
+
60
+ # Check the procsd installed path:
61
+ $ sudo which procsd
62
+ /usr/local/bin/procsd
58
63
  ```
64
+ > Like you see, Procsd installed to the system bin path /usr/local/bin/ and can be accessed from any user and kind of connection (including default Capistrano non-interactive, non-login ssh connection)
65
+
66
+ #### Local user installation using Rbenv
59
67
 
60
- Or, if you already use [Rbenv](https://github.com/rbenv/rbenv) you can do instead following:
68
+ There is another way if you don't want to install Ruby system-wide for some reason and use [Rbenv](https://github.com/rbenv/rbenv) instead:
61
69
 
62
70
  Add `procsd` gem to your application Gemfile:
63
71
 
@@ -96,6 +104,8 @@ append :bundle_bins, "procsd"
96
104
 
97
105
  At the first deploy `$ bundle exec cap production deploy` app services will be created and started. You will be prompted to fill in remote user password (make sure that your deploy user added to the sudo group `adduser deploy sudo`).
98
106
 
107
+ ### Start/Stop/Restart services without sudo password
108
+
99
109
  If you don't want to type password each time while deploying, you can add start/stop/restart commands to the sudoers file:
100
110
 
101
111
  1. Login to the remote server, `cd` into application folder, and type `$ procsd config sudoers`. Example:
@@ -111,7 +121,7 @@ deploy ALL=NOPASSWD: /bin/systemctl start sample_app.target, /bin/systemctl stop
111
121
  Now try to call restart task `$ bundle exec cap production procsd:restart`. If all is fine, task will execute without password prompt.
112
122
 
113
123
 
114
- **Also, steps above can be done automatically:**
124
+ **Note: steps above can be done automatically as well:**
115
125
 
116
126
  ```ruby
117
127
  # config/deploy.rb
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "capistrano-procsd"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["Victor Afanasev"]
9
9
  spec.email = ["vicfreefly@gmail.com"]
10
10
 
@@ -69,7 +69,7 @@ namespace :procsd do
69
69
  arguments = args[:arguments]
70
70
 
71
71
  on roles(:all) do
72
- ssh_exec cmd_with_env("procsd status #{arguments}")
72
+ ssh_exec cmd_with_env("procsd status #{arguments}"), task_name: :status
73
73
  end
74
74
  end
75
75
 
@@ -78,14 +78,14 @@ namespace :procsd do
78
78
  arguments = args[:arguments]
79
79
 
80
80
  on roles(:all) do
81
- ssh_exec cmd_with_env("procsd logs #{arguments}")
81
+ ssh_exec cmd_with_env("procsd logs #{arguments}"), task_name: :logs
82
82
  end
83
83
  end
84
84
 
85
85
  desc "List all services"
86
86
  task :list do
87
87
  on roles(:all) do
88
- ssh_exec cmd_with_env("procsd list")
88
+ ssh_exec cmd_with_env("procsd list"), task_name: :list
89
89
  end
90
90
  end
91
91
 
@@ -97,19 +97,19 @@ namespace :procsd do
97
97
  raise "Please provide a command to run" if cmd.nil? || cmd.empty?
98
98
 
99
99
  on roles(:all) do
100
- ssh_exec cmd_with_env(cmd)
100
+ ssh_exec cmd_with_env(cmd), task_name: :run
101
101
  end
102
102
  end
103
103
 
104
104
  ###
105
105
 
106
106
  private def cmd_with_env(cmd)
107
- cmd = cmd.split(" ", 2)
107
+ cmd = cmd.strip.split(" ", 2)
108
108
  cmd[0] = cmd[0].to_sym
109
109
  command(cmd, {}).to_s
110
110
  end
111
111
 
112
- private def ssh_exec(command)
112
+ private def ssh_exec(command, task_name:)
113
113
  full_command = %W(ssh #{host.user}@#{host.hostname} -t)
114
114
 
115
115
  ssh_options = fetch(:ssh_options, {})
@@ -120,7 +120,8 @@ namespace :procsd do
120
120
  command = "'cd #{release_path} && #{command}'"
121
121
  full_command << command
122
122
 
123
- puts "Executing: `#{full_command.join(' ')}`\n\n"
124
- exec full_command.join(" ")
123
+ cmd = full_command.join(" ")
124
+ puts Airbrussh::Colors.blue("procsd:#{task_name} ") + Airbrussh::Colors.yellow(cmd)
125
+ exec cmd
125
126
  end
126
127
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-procsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Afanasev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-09 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano