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 +4 -4
- data/README.md +15 -5
- data/capistrano-procsd.gemspec +1 -1
- data/lib/capistrano/tasks/procsd.rake +9 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 678f36b61233ee76105780721fa080ebb1408fea53b2721cf1af759f7506e6b0
|
4
|
+
data.tar.gz: 45f9889af566c91b88f864d8cb1619b2298311e986c6421ffc45c27108b6b357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
###
|
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
|
-
|
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
|
-
**
|
124
|
+
**Note: steps above can be done automatically as well:**
|
115
125
|
|
116
126
|
```ruby
|
117
127
|
# config/deploy.rb
|
data/capistrano-procsd.gemspec
CHANGED
@@ -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
|
-
|
124
|
-
|
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.
|
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-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|