rails_com 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +11 -3
- data/app/assets/javascripts/rails_com/application.js +1 -1
- data/app/assets/javascripts/rails_com/common.js +32 -0
- data/app/assets/javascripts/rails_com/fetch_xhr_script.js +53 -0
- data/app/assets/javascripts/rails_com/footer.js +3 -0
- data/app/assets/stylesheets/rails_com/application.css +0 -1
- data/app/controllers/common_controller.rb +18 -0
- data/app/controllers/concerns/the_common_api.rb +15 -3
- data/app/helpers/rails_com/active_helper.rb +17 -6
- data/app/helpers/rails_com_helper.rb +6 -3
- data/app/models/state_machine.rb +5 -4
- data/app/views/shared/_alert.html.erb +1 -5
- data/app/views/shared/_error_messages.html.erb +1 -7
- data/app/views/shared/_locales.html.erb +8 -0
- data/config/initializers/time_format.rb +1 -0
- data/config/locales/en.yml +8 -6
- data/config/routes.rb +7 -0
- data/lib/assets/javascripts/semantic.js +11 -0
- data/lib/mina/puma.rb +63 -0
- data/lib/mina/sidekiq.rb +65 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.eot +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.otf +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.svg +946 -2670
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.ttf +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff +0 -0
- data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff2 +0 -0
- data/lib/nondigest_assets/{images → fonts}/themes/default/assets/images/flags.png +0 -0
- data/lib/rails_com/controller_helper.rb +26 -1
- data/lib/rails_com/controllers.rb +8 -0
- data/lib/rails_com/core_ext/nil.rb +1 -1
- data/lib/rails_com/helpers/uid_helper.rb +24 -4
- data/lib/rails_com/rails_ext/scaffold_generator.rb +14 -0
- data/lib/rails_com/rails_ext/template_renderer.rb +22 -0
- data/lib/rails_com/routes.rb +12 -8
- data/lib/rails_com/sprockets/non_digest_assets.rb +0 -18
- data/lib/rails_com/version.rb +1 -1
- data/lib/rails_com.rb +11 -2
- data/lib/templates/erb/scaffold/_form.html.erb.tt +12 -0
- data/lib/templates/erb/scaffold/_search_form.html.erb.tt +7 -0
- data/lib/templates/erb/scaffold/edit.html.erb.tt +14 -0
- data/lib/templates/erb/scaffold/index.html.erb.tt +43 -0
- data/lib/templates/erb/scaffold/new.html.erb.tt +13 -0
- data/lib/templates/erb/scaffold/show.html.erb.tt +7 -0
- data/lib/templates/rails/scaffold_controller/controller.rb.tt +53 -0
- metadata +25 -16
- data/lib/assets/stylesheets/semantic.css +0 -19466
- data/lib/rails_com/helpers/qiniu_helper.rb +0 -84
- data/lib/rails_com/sprockets/qiniu_exporter.rb +0 -21
- data/lib/rails_com/sprockets.rb +0 -15
- data/lib/templates/erb/scaffold/_form.html.erb +0 -19
- data/lib/templates/erb/scaffold/edit.html.erb +0 -2
- data/lib/templates/erb/scaffold/index.html.erb +0 -36
- data/lib/templates/erb/scaffold/new.html.erb +0 -1
- data/lib/templates/erb/scaffold/show.html.erb +0 -13
- data/lib/templates/rails/scaffold_controller/controller.rb +0 -47
data/lib/mina/puma.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
set :puma_cmd, -> { "#{fetch :bundle_prefix} puma -e #{fetch :rails_env}" }
|
2
|
+
set :pumactl_cmd, -> { "#{fetch :bundle_prefix} pumactl" }
|
3
|
+
set :puma_socket, -> { "#{fetch :current_path}/tmp/pids/puma.pid" }
|
4
|
+
|
5
|
+
namespace :puma do
|
6
|
+
|
7
|
+
desc 'Start puma'
|
8
|
+
task start: :remote_environment do
|
9
|
+
in_path(fetch(:current_path)) do
|
10
|
+
command %{
|
11
|
+
if [[ -e #{fetch :puma_socket} ]]
|
12
|
+
then
|
13
|
+
echo 'Puma is already running!'
|
14
|
+
else
|
15
|
+
#{fetch :puma_cmd}
|
16
|
+
fi
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Stop puma'
|
22
|
+
task stop: :remote_environment do
|
23
|
+
in_path(fetch(:current_path)) do
|
24
|
+
command %{
|
25
|
+
if [[ -e #{fetch :puma_socket} ]]
|
26
|
+
then
|
27
|
+
#{fetch :pumactl_cmd} stop
|
28
|
+
else
|
29
|
+
echo 'Puma is not running!'
|
30
|
+
fi
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Restart puma'
|
36
|
+
task restart: :remote_environment do
|
37
|
+
in_path(fetch(:current_path)) do
|
38
|
+
command %{
|
39
|
+
if [[ -e #{fetch :puma_socket} ]]
|
40
|
+
then
|
41
|
+
#{fetch :pumactl_cmd} restart
|
42
|
+
else
|
43
|
+
echo 'Puma is not running! Start Now!' && #{fetch :puma_cmd}
|
44
|
+
fi
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Restart puma (phased restart)'
|
50
|
+
task phased_restart: :remote_environment do
|
51
|
+
in_path(fetch(:current_path)) do
|
52
|
+
command %{
|
53
|
+
if [[ -e #{fetch :puma_socket} ]]
|
54
|
+
then
|
55
|
+
#{fetch :pumactl_cmd} phased-restart
|
56
|
+
else
|
57
|
+
echo 'Puma is not running! Start Now!' && #{fetch :puma_cmd}
|
58
|
+
fi
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/lib/mina/sidekiq.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
set :sidekiq, -> { "#{fetch :bundle_prefix} sidekiq -d" }
|
2
|
+
set :sidekiqctl, -> { "#{fetch :bundle_prefix} sidekiqctl" }
|
3
|
+
set :sidekiq_config, -> { "#{fetch :current_path}/config/sidekiq.yml" }
|
4
|
+
set :sidekiq_pid, -> { "#{fetch :current_path}/tmp/pids/sidekiq.pid" }
|
5
|
+
set :sidekiq_processes, 2
|
6
|
+
set :sidekiq_timeout, 10
|
7
|
+
|
8
|
+
namespace :sidekiq do
|
9
|
+
|
10
|
+
def for_each_process(&block)
|
11
|
+
fetch(:sidekiq_processes).times do |idx|
|
12
|
+
if idx == 0
|
13
|
+
pid_file = fetch :sidekiq_pid
|
14
|
+
else
|
15
|
+
pid_file = "#{fetch :sidekiq_pid}-#{idx}"
|
16
|
+
end
|
17
|
+
|
18
|
+
yield(pid_file, idx)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Quiet sidekiq (stop accepting new work)'
|
23
|
+
task quiet: :remote_environment do
|
24
|
+
comment 'Quiet sidekiq (stop accepting new work)'
|
25
|
+
for_each_process do |pid_file, idx|
|
26
|
+
command %{
|
27
|
+
if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
|
28
|
+
cd "#{deploy_to}/#{current_path}"
|
29
|
+
#{echo_cmd %{#{sidekiqctl} quiet #{pid_file}} }
|
30
|
+
else
|
31
|
+
echo 'Skip quiet command (no pid file found)'
|
32
|
+
fi
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Stop sidekiq'
|
38
|
+
task stop: :remote_environment do
|
39
|
+
comment 'Stop sidekiq!'
|
40
|
+
|
41
|
+
for_each_process do |pid_file, _|
|
42
|
+
in_path fetch(:current_path) do
|
43
|
+
command %{ #{fetch :sidekiqctl} stop #{pid_file} #{fetch :sidekiq_timeout}}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Start sidekiq'
|
49
|
+
task start: :remote_environment do
|
50
|
+
comment 'Start sidekiq!'
|
51
|
+
|
52
|
+
for_each_process do |pid_file, idx|
|
53
|
+
in_path fetch(:current_path) do
|
54
|
+
command %{ #{fetch :sidekiq} -d -i #{idx} -P #{pid_file} }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc 'Restart sidekiq'
|
60
|
+
task :restart do
|
61
|
+
invoke :'sidekiq:stop'
|
62
|
+
invoke :'sidekiq:start'
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
Binary file
|
File without changes
|