capistrano-addon-fm 0.1.0 → 0.1.2

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: fc7d4b0461652faa8410d3fc1e523d8859e39658e72efcc280bb7ac85cb8499b
4
- data.tar.gz: f174c148881f0c23c6e437cf412edc2e3f94df850304e025eb944f736e91d93a
3
+ metadata.gz: 3bd77cf936fe7b355ceef1d43344d55af39f0040afaebdc441154e2571df8280
4
+ data.tar.gz: 6430cd5a453b92599abe528d09fdac247719f1bcca27a9d6e8ed93fd42aecef3
5
5
  SHA512:
6
- metadata.gz: adcffbf7e1fad3b5225f3726bd6bc3ee07435553cab44610b30e045f3518343826d6448d66399f3abcee85aad72db9c76b7dd2ff6be1b3b06fad4b3337383791
7
- data.tar.gz: 2060cf4a8fa6ec36eab7ebd411228785a4178c591dbb485ba471d7c5c6bc6a48ca1d317fe9e4bb01bc8d36b033bc5308347f2b7e177370ceff377cd84090d02c
6
+ metadata.gz: c6e61dc7bab5dfe662f80b1ecc857c9f4241bf2f8ade82f42122ef3676edd221411fd4de924ccd4de553ff513b450ce5f26a0a8e0c9de298d8a09d2bb417dfa4
7
+ data.tar.gz: d7f8490624c7f01adbb261cc159e335f27c87aa42fc140e1b96c6fa94dc0466120ce4a8cc215542e2b4de32796926de01ebd696bd10a5143dc5f2e253c73d311
data/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.1.1] - 2025-02-18
5
+ ### Added
6
+ - add php-fpm tasks
4
7
  ## [0.1.0] - 2025-02-18
5
8
  ### Added
6
9
  - add generic tasks - documented in README.md
data/README.md CHANGED
@@ -33,7 +33,13 @@ new tasks (example run: cap prod TASK - replace 'prod' with your stage (devel/lo
33
33
  cap prod nginx:reload
34
34
  cap prod nginx:restart
35
35
  cap prod nginx:status
36
- #### fpm related commands: TO-BE-ADDED
36
+ #### php-fpm related commands
37
+ cap prod fpm:start
38
+ cap prod fpm:stop
39
+ cap prod fpm:reload
40
+ cap prod fpm:restart
41
+ cap prod fpm:status
42
+ cap prod fpm:cfg:show Run `cat /etc/php/8.2/fpm/pool.d/www.conf | egrep -v '^ *(#|;|$)'`
37
43
  #### system related commands:
38
44
  cap prod php Run 'php -v'
39
45
  cap prod composer Run 'composer --version'
@@ -75,6 +81,8 @@ set :local_path, './'
75
81
  set :file_to_encrypt, 'cap-secrets-LOCAL.txt'
76
82
  set :file_to_decrypt, 'cap-secrets.enc.b64'
77
83
  set :encryption_key_file, 'cap-secrets-encryption-key-LOCAL.txt'
84
+ # php-fpm
85
+ set :USE_PHP_VERSION, "8.4"
78
86
  ```
79
87
 
80
88
  ## env-with-secrets
@@ -116,6 +124,13 @@ set :encryption_key_file, 'cap-secrets-encryption-key-LOCAL.txt'
116
124
  - `cap-secrets-LOCAL.txt`
117
125
  - `cap-secrets-encryption-key-LOCAL.txt`
118
126
 
127
+ ## php-fpm
128
+ - For each `server` line, you can specify which php version to use via `use_php_version`. Example:
129
+ - `server "web1", user: "user1", roles: %w{ app web etc }, use_php_version: 8.5`
130
+ - You can also specify (deploy.rb/{stage}.rb) a default version to use; this will be used if server's `use_php_version` is not set
131
+ - `set :USE_PHP_VERSION, "8.4"`
132
+ - If none is set, then default `8.2` will be used
133
+
119
134
  ## License
120
135
 
121
136
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,3 +1,5 @@
1
+ require 'tempfile'
2
+
1
3
  namespace "env" do
2
4
  # Set default values
3
5
  set :default_local_path, './'
@@ -66,9 +68,17 @@ namespace "env" do
66
68
  secrets[$1]
67
69
  end
68
70
  end
71
+ decrypted_content = decrypted_lines.join
72
+
73
+ # Create a temporary local file with the decrypted content
74
+ Tempfile.open('.env.tmp') do |tempfile|
75
+ tempfile.write(decrypted_content)
76
+ tempfile.write("\n")
77
+ tempfile.close
69
78
 
70
- # Write the modified .env file back to the server
71
- execute :echo, "'#{decrypted_lines.join}' > #{shared_path}/.env.tmp", verbosity: :DEBUG
79
+ # Upload the temporary file to the remote server
80
+ upload! tempfile.path, "#{shared_path}/.env.tmp", verbosity: :DEBUG
81
+ end
72
82
  end
73
83
  end
74
84
  namespace :local do
@@ -0,0 +1,40 @@
1
+
2
+ set :USE_PHP_VERSION_INTERNAL, "8.2"
3
+
4
+ namespace "fpm" do
5
+ task "start" do
6
+ on release_roles(:fpm) do |host|
7
+ sudo "systemctl start php#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}-fpm.service"
8
+ end
9
+ end
10
+ task "stop" do
11
+ on release_roles(:fpm) do |host|
12
+ sudo "systemctl stop php#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}-fpm.service"
13
+ end
14
+ end
15
+ task "reload" do
16
+ on release_roles(:fpm) do |host|
17
+ sudo "systemctl reload php#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}-fpm.service"
18
+ end
19
+ end
20
+ task "restart" do
21
+ on release_roles(:fpm) do |host|
22
+ sudo "systemctl restart php#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}-fpm.service"
23
+ end
24
+ end
25
+ task "status" do
26
+ on release_roles(:fpm) do |host|
27
+ sudo "systemctl status php#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}-fpm.service"
28
+ end
29
+ end
30
+ task "cfg:show" do
31
+ on release_roles(:fpm) do |host|
32
+ execute "cat /etc/php/#{host.properties.use_php_version || fetch(:USE_PHP_VERSION, fetch(:USE_PHP_VERSION_INTERNAL))}/fpm/pool.d/www.conf | egrep -v '^\s*(#|;|$)'", raise_on_non_zero_exit: false # filter ` space + # ` too
33
+ end
34
+ end
35
+ task "ps" do
36
+ on release_roles(:fpm) do
37
+ execute "ps aux | grep fpm"
38
+ end
39
+ end
40
+ end
@@ -3,7 +3,7 @@
3
3
  module Capistrano
4
4
  module Addon
5
5
  module Fm
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.2"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-addon-fm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florin Motoc
@@ -40,6 +40,7 @@ files:
40
40
  - lib/capistrano/addon/fm.rb
41
41
  - lib/capistrano/addon/fm/tasks/custom.rake
42
42
  - lib/capistrano/addon/fm/tasks/env-with-secrets.rake
43
+ - lib/capistrano/addon/fm/tasks/fpm.rake
43
44
  - lib/capistrano/addon/fm/tasks/mysql.rake
44
45
  - lib/capistrano/addon/fm/tasks/nginx.rake
45
46
  - lib/capistrano/addon/fm/tasks/supervisor.rake