mina-puma 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64507fce87b0467be63a81f7acfb952d19476e66
4
- data.tar.gz: 7f57c5e069b956d7e9c8834fbbc3ca4a7cb8b90b
3
+ metadata.gz: 7dec73c6a879f7fbe406f1320381b4af3a642c7e
4
+ data.tar.gz: 7cc245b86271c1d7563af03c03e5906e8d5cf969
5
5
  SHA512:
6
- metadata.gz: 143ce3a9acbc2274afe6e3605fc5254afdca9a349bda0d6120435fd794b811d8b49026b1b92668ef8900a4a56b864bf8dc3b5a260b84118444a32580e7091e61
7
- data.tar.gz: 919a68331f02d374be14c005156129fb67f59f75bb6de319ae7048b86870fd04a251cc9070d5c07151b8a3814ffa1aa0b1864142cf365310db51584e4047cf24
6
+ metadata.gz: e5ea8367bb5ce02bd36dba509fed62db67a8cf44d57090e4fcbda402b9f294e4ab4ee6336a313671282c4f24a30ebe0f3f11575daee5dfaabf4a2015c12adc22
7
+ data.tar.gz: 69a982baf39e9def2d856f2cc25afd7895f62185bff9af04c56b1e206941b0b50bfdf553a33780199d5f47582d5b56fcef8c8827ee24e787d0bd2df41bb8390c
data/README.md CHANGED
@@ -1,52 +1,84 @@
1
- # Mina::Puma
1
+ # Mina Puma
2
2
 
3
- Puma tasks for Mina deployment.
3
+ [Mina](https://github.com/nadarei/mina) tasks for handle with
4
+ [Puma](https://github.com/puma/puma).
5
+
6
+ This gem provides several mina tasks:
7
+
8
+ mina puma:restart # Restart puma
9
+ mina puma:start # Start puma
10
+ mina puma:stop # Stop puma
4
11
 
5
12
  ## Installation
6
13
 
7
14
  Add this line to your application's Gemfile:
8
15
 
9
- gem 'mina-puma', require: false
16
+ gem 'mina-puma', :require => false
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install mina-puma
10
25
 
11
26
  ## Usage
12
27
 
13
- # config/deploy.rb
14
- ...
28
+ Add this to your `config/deploy.rb` file:
29
+
15
30
  require 'mina/puma'
16
31
 
17
- # Add pids and sockets to shared paths
18
- set :shared_paths, %w(log tmp/sockets config/database.yml)
32
+ Make sure the following settings are set in your `config/deploy.rb`:
33
+
34
+ * `deploy_to` - deployment path
35
+
36
+ Make sure the following directories exists on your server:
37
+
38
+ * `shared/tmp/sockets` - directory for socket files.
39
+ * `shared/tmp/pids` - direcotry for pid files.
40
+
41
+ OR you can set other directories by setting follow variables:
42
+
43
+ * `puma_socket` - puma socket file, default is `shared/tmp/sockets/puma.sock`
44
+ * `puma_pid` - puma pid file, default `shared/tmp/pids/puma.pid`
45
+ * `puma_state` - puma state file, default `shared/tmp/sockets/puma.state`
46
+ * `pumactl_socket` - pumactl socket file, default `shared/tmp/sockets/pumactl.sock`
47
+
48
+ Then:
49
+
50
+ ```
51
+ $ mina puma:start
52
+ ```
53
+
54
+ ## Example
55
+
56
+ require 'mina/puma'
57
+
58
+ task :setup => :environment do
59
+ # Puma needs a place to store its pid file and socket file.
60
+ queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/sockets")
61
+ queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/sockets")
62
+ queue! %(#{deploy_to}/#{shared_path}/tmp/pids")
63
+ queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/pids")
19
64
 
20
- ...
21
- task :setup do
22
65
  ...
23
- queue! %[mkdir -p "{deploy_to}/shared/tmp/sockets/"]
66
+
24
67
  end
25
68
 
26
69
  task :deploy do
27
70
  deploy do
28
71
  invoke :'git:clone'
72
+ invoke :'deploy:link_shared_paths'
29
73
  ...
30
74
 
31
75
  to :launch do
32
- ...
33
- invoke :'puma:restart'
76
+ ...
77
+ invoke :'puma:restart'
34
78
  end
35
79
  end
36
80
  end
37
81
 
38
- Available commands:
39
-
40
- mina puma:start
41
- mina puma:stop
42
- mina puma:restart
43
-
44
- Default settings:
45
-
46
- set :puma_socket, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.sock" }
47
- set :puma_ctl, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/pumactl.sock" }
48
- set :puma_state, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.state" }
49
-
50
82
  ## Contributing
51
83
 
52
84
  1. Fork it
@@ -1,35 +1,56 @@
1
- set_default :puma_socket, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.sock" }
2
- set_default :puma_ctl, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/pumactl.sock" }
3
- set_default :puma_state, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.state" }
4
-
1
+ require 'mina/bundler'
2
+ require 'mina/rails'
5
3
 
6
4
  namespace :puma do
5
+ set :web_server, :puma
6
+
7
+ set_default :puma_role, -> { user }
8
+ set_default :puma_env, -> { fetch(:rails_env, 'production') }
9
+ set_default :puma_config, -> { "#{deploy_to}/#{shared_path}/config/puma.rb" }
10
+ set_default :puma_socket, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.sock" }
11
+ set_default :puma_state, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/puma.state" }
12
+ set_default :puma_pid, -> { "#{deploy_to}/#{shared_path}/tmp/pids/puma.pid" }
13
+ set_default :puma_cmd, -> { "#{bundle_prefix} puma" }
14
+ set_default :pumactl_cmd, -> { "#{bundle_prefix} pumactl" }
15
+ set_default :pumactl_socket, -> { "#{deploy_to}/#{shared_path}/tmp/sockets/pumactl.sock" }
16
+
7
17
  desc 'Start puma'
8
- task start: :environment do
9
- queue %[cd #{deploy_to}/#{current_path} && bundle exec puma #{start_options}]
18
+ task :start => :environment do
19
+ in_directory "#{deploy_to}/#{current_path}" do
20
+ queue! %(#{puma_cmd} #{start_options})
21
+ end
10
22
  end
11
23
 
12
24
  desc 'Stop puma'
13
25
  task stop: :environment do
14
- queue %[cd #{deploy_to}/#{current_path} && bundle exec pumactl -S #{puma_state} stop]
26
+ in_directory "#{deploy_to}/#{current_path}" do
27
+ queue! %(#{pumactl_cmd} -S #{puma_state} stop)
28
+ end
15
29
  end
16
30
 
17
31
  desc 'Restart puma'
18
32
  task restart: :environment do
19
- queue %[
20
- if [ -f #{puma_ctl} ]; then
21
- cd #{deploy_to}/#{current_path} && bundle exec pumactl -S #{puma_state} restart
33
+ in_directory "#{deploy_to}/#{current_path}" do
34
+ if check_exists?(pumactl_socket)
35
+ queue! %(#{pumactl_cmd} -S #{puma_state} restart)
22
36
  else
23
- cd #{deploy_to}/#{current_path} && bundle exec puma #{start_options}
24
- fi
25
- ]
37
+ queue! %(#{puma_cmd} #{start_options})
38
+ end
39
+ end
26
40
  end
27
- end
28
41
 
29
- def start_options
30
- if File.exists?("./config/puma.rb")
31
- "-q -d -e #{rails_env} -C ./config/puma.rb"
32
- else
33
- "-q -d -e #{rails_env} -b 'unix://#{puma_socket}' -S #{puma_state} --control 'unix://#{puma_ctl}'"
34
- end
35
- end
42
+ private
43
+
44
+ def start_options
45
+ if check_exists?(puma_config)
46
+ "-q -d -e #{puma_env} -C #{puma_config}"
47
+ else
48
+ "-q -d -e #{puma_env} -b 'unix://#{puma_socket}' -S #{puma_state} --control 'unix://#{pumactl_socket}'"
49
+ end
50
+ end
51
+
52
+ def check_exists?(file)
53
+ boolean = capture("if [ -a '#{file}' ]; then echo 'yes'; else echo 'no'; fi").chomp
54
+ boolean == 'yes' ? true : false
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Puma
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Sandelius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-22 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mina