buildable 1.3.4 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- N2ViNGI3Yjc5MTAyZjExZDBlODhjMzU5ZGQ1YzY2ODMxZTFlYTk0Yg==
5
- data.tar.gz: !binary |-
6
- YzU0YWE5ZTg4M2E5NDc4NGQ4MDU4MjBkZGNmOWIxYzk1Mjg0N2M2Mg==
2
+ SHA1:
3
+ metadata.gz: 3fb6431892645540bda1486ee99ec7df9dc528ae
4
+ data.tar.gz: 340f3df09f4afef6ea3939ccfbfd76948726cc80
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OGQ1ODJjZjI2MzgxMDhjZTA0ZjJkMjI1MTA4ZGJlMjQyOTE1MWYyNTI5MzEx
10
- MmFmZDY3MmQzMGIxNTk0NjY2ZDRkMDBhZmMyYjg1MjM5NjQ1OWFjNWRiYWQ2
11
- NzEyYjFjNGY2NGMxMTJiZWIwNzM3ZGMzZjUxZWZmN2Y1OTcxZmI=
12
- data.tar.gz: !binary |-
13
- OGZiN2Q3ZGYxOWY0NTNhMzkzNGM4NTM0OGU4NDlhZDQzOGRmNThiZTVkOTJj
14
- ZjlhMjJmYTZiMWM0ZjliZGUwMTJkMTQwYmMxZTkyMjJkMDk0MDliYWRjZTFj
15
- NWQ2NGIxNWEyN2YwNzZmMDIzMTRmYzlkM2UyMmVlMDQzYmMxNzk=
6
+ metadata.gz: 93a0e892bad4a7108959c1c6e055afba8c15ec4c3aeedd133a88888b7eadb4d65ebe279cfe185869947daaf283fd1776ef6522136a7e956a0d27ea59becc6ebf
7
+ data.tar.gz: c2dbddb901773230271e0a1dd92d5098ce5004692ea4a04dc76128d8999655d5b4af4c2dfcfea31b020e857759bf324d2d176207ea4c63cfd07369ae5fcd2fe4
data/README.md CHANGED
@@ -12,7 +12,9 @@ Sim criar gem é muito mais simples, se você estiver fazendo algo para rubistas
12
12
  Primeiramente adicione o *Buildable* no seu Gemfile
13
13
 
14
14
  ```
15
- gem 'buildable'
15
+ group :build do
16
+ gem 'buildable'
17
+ end
16
18
  ```
17
19
 
18
20
  Execute o bunlder para instalar a gem
@@ -23,14 +25,15 @@ Execute o bunlder para instalar a gem
23
25
 
24
26
  Agora basta criar os arquivos de configuração do seu projeto (este passo é feito apenas uma vez)
25
27
 
26
- ```bash
28
+ ```shell
27
29
  $ buildable init
28
30
  ```
29
31
 
30
32
  Este comando criará os seguintes arquivos:
31
33
 
32
- #TO BE CONTINUED
33
-
34
+ * .buildable.yml: arquivo de configuração do projeto
35
+ * production.env: arquivo de configuração do ambiente (ver: [foreman](https://github.com/ddollar/foreman))
36
+ * Procfile: arquivo de configuração do executável (ver: [foreman](https://github.com/ddollar/foreman))
34
37
 
35
38
  O Buildable pode ser utilizado de duas formas seu executável ou via rake (ideal para automatização do build),
36
39
 
@@ -8,17 +8,18 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Buildable::VERSION
9
9
  spec.authors = ["Alexandre Prates"]
10
10
  spec.email = ["ajfprates@gmail.com"]
11
- spec.summary = %q{Gem para criar pacotes (debian) para deploy de projetos ruby.}
11
+ spec.summary = %q{Gem para criação de pacotes deb}
12
+ spec.description = %q{Gem para criação de pacotes deb para distribuição de seus projetos em ambientes Debian}
12
13
  spec.license = "MIT"
14
+ spec.homepage = 'https://github.com/r7com/buildable'
13
15
 
14
16
  spec.files = `git ls-files -z`.split("\x0")
15
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
18
  spec.test_files = spec.files.grep(%r{^(spec)/})
17
19
  spec.require_paths = ["lib", "lib/tasks", "lib/buildable"]
18
20
 
19
- spec.add_runtime_dependency "rake"
20
- spec.add_runtime_dependency "fpm", ">= 1.3.3"
21
- spec.add_runtime_dependency "foreman", ">= 0.78.0"
22
- spec.add_runtime_dependency "foreman-export-initscript"
23
- spec.add_runtime_dependency "configureasy", ">= 1.0.0"
21
+ spec.add_runtime_dependency "rake", '~> 0'
22
+ spec.add_runtime_dependency 'fpm', '~> 1.3', '>= 1.3.3'
23
+ spec.add_runtime_dependency 'foreman', '~> 0.78', '>= 0.78.0'
24
+ spec.add_runtime_dependency 'configureasy', '~> 1.0', '>= 1.0.0'
24
25
  end
@@ -1,5 +1,4 @@
1
- require 'bundler'
2
- Bundler.require(:default)
1
+ require 'configureasy'
3
2
 
4
3
  module Buildable
5
4
  require_relative 'core_ext/hash'
@@ -9,7 +8,7 @@ module Buildable
9
8
  require_relative 'buildable/recipe'
10
9
  require_relative 'buildable/rake_helper'
11
10
 
12
- include Configureasy
11
+ include ::Configureasy
13
12
  load_config '.buildable', as: 'config', path: '.'
14
13
 
15
14
  BUILD_DIR = './.build'
@@ -26,6 +26,7 @@ module Buildable::Recipe
26
26
  end
27
27
 
28
28
  recipe :make_init_script do
29
+ # To make the initd script i'm using foreman's bluepill export with custom template
29
30
  puts "* Generating init scripts"
30
31
  params = {
31
32
  '--user' => Buildable.config.app_user,
@@ -36,10 +37,11 @@ module Buildable::Recipe
36
37
  '-f' => 'Procfile',
37
38
  '-d' => Buildable.config.root_dir
38
39
  }
39
- Buildable::Shell.do "foreman export initscript #{Buildable.initd_folder}", params
40
-
40
+ Buildable::Shell.do "foreman export bluepill #{Buildable.initd_folder}", params
41
41
  raise "Can't generate init scripts" unless Buildable::Shell.success?
42
+
42
43
  initscript = File.join Buildable.initd_folder, Buildable.config.project_name
44
+ FileUtils.move "#{initscript}.pill", initscript
43
45
  FileUtils.chmod "+x", initscript
44
46
  end
45
47
 
@@ -61,7 +63,7 @@ module Buildable::Recipe
61
63
  '-C' => "#{Buildable::BUILD_ROOT_DIR} ."
62
64
  }
63
65
 
64
- result = Buildable::Shell.do_quiet 'bundle exec fpm', params
66
+ result = Buildable::Shell.do_quiet 'fpm', params
65
67
  raise "Can't create package, error:\n#{result}" unless Buildable::Shell.success?
66
68
  package_name = result.match(/:path=>"\.\/pkg\/([^"]*)/)[1]
67
69
  puts "\tPackage created #{package_name}"
@@ -1,3 +1,3 @@
1
1
  module Buildable
2
- VERSION = "1.3.4"
2
+ VERSION = "1.4.2"
3
3
  end
@@ -0,0 +1,109 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: <%= app %>
4
+ # Required-Start: $remote_fs $syslog
5
+ # Required-Stop: $remote_fs $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Generated initscript for <%= app %>
9
+ # Description: This file starts <%= app %>. It should be placed in /etc/init.d
10
+ ### END INIT INFO
11
+
12
+ # Auto generated by Buildable
13
+
14
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
+ NAME=<%= app %>
16
+ USERNAME=<%= user %>
17
+ <% engine.each_process do |name, process| -%>
18
+ <%= name %>_pidfile=/var/run/<%= app %>_<%= name %>.pid
19
+ <% end -%>
20
+
21
+ [ -r /lib/lsb/init-functions ] &&. /lib/lsb/init-functions
22
+
23
+ #
24
+ # Function that starts the service
25
+ #
26
+ do_start()
27
+ {
28
+ <% engine.each_process do |name, process| -%>
29
+ log_daemon_msg "start <%= name %>"
30
+ <%= name %>_running
31
+ if [ $? -ne 0 ]; then
32
+ start_<%= name %>
33
+ else
34
+ log_end_msg 1
35
+ log_action_msg "<%= name %> it is already running!"
36
+ fi
37
+
38
+ <% end -%>
39
+ }
40
+
41
+ #
42
+ # Function that stops the service
43
+ #
44
+ do_stop()
45
+ {
46
+ <% engine.each_process do |name, process| -%>
47
+ log_daemon_msg "stop <%= name %>"
48
+ kill `cat $<%= name %>_pidfile 2> /dev/null` 2> /dev/null && rm $<%= name %>_pidfile 2> /dev/null
49
+ log_end_msg $?
50
+
51
+ <% end -%>
52
+ }
53
+
54
+ #
55
+ # Function to show service status
56
+ #
57
+ show_status()
58
+ {
59
+ <% engine.process_names.each do |name| -%>
60
+ <%= name %>_running && log_action_msg "<%= app %> <%= name %> is running!" || log_action_msg "<%= app %> <%= name %> is not running"
61
+
62
+ <% end -%>
63
+ }
64
+
65
+
66
+ #
67
+ # Support functions
68
+ #
69
+ <% engine.each_process do |name, process| -%>
70
+ start_<%= name %>()
71
+ {
72
+ su - $USERNAME <<EOS | cut -d ' ' -f 2 > $<%= name %>_pidfile
73
+ cd <%= engine.root %>
74
+ <%= engine.environment.collect { |k,v| "#{k}=#{v} " }.join %><%= process.command %> > /dev/null 2>&1 &
75
+ jobs -l
76
+ EOS
77
+ log_end_msg $?
78
+ }
79
+
80
+ <%= name %>_running()
81
+ {
82
+ ps -p $(cat $<%= name %>_pidfile 2> /dev/null) > /dev/null 2>&1
83
+ }
84
+
85
+ <% end -%>
86
+
87
+ case "$1" in
88
+ start)
89
+ log_action_msg "Starting $NAME"
90
+ do_start
91
+ ;;
92
+ stop)
93
+ log_action_msg "Stopping $NAME"
94
+ do_stop
95
+ ;;
96
+ status)
97
+ show_status
98
+ ;;
99
+ restart)
100
+ log_action_msg "Restarting $NAME"
101
+ do_stop
102
+ sleep 1
103
+ do_start
104
+ ;;
105
+ *)
106
+ echo "Usage: <%= app %> {start|stop|status|restart}" >&2
107
+ exit 3
108
+ ;;
109
+ esac
metadata CHANGED
@@ -1,86 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Prates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fpm
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ - - ">="
32
35
  - !ruby/object:Gem::Version
33
36
  version: 1.3.3
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ! '>='
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.3'
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 1.3.3
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: foreman
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ! '>='
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 0.78.0
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
+ version: '0.78'
54
+ - - ">="
53
55
  - !ruby/object:Gem::Version
54
56
  version: 0.78.0
55
- - !ruby/object:Gem::Dependency
56
- name: foreman-export-initscript
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
57
  type: :runtime
63
58
  prerelease: false
64
59
  version_requirements: !ruby/object:Gem::Requirement
65
60
  requirements:
66
- - - ! '>='
61
+ - - "~>"
67
62
  - !ruby/object:Gem::Version
68
- version: '0'
63
+ version: '0.78'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.78.0
69
67
  - !ruby/object:Gem::Dependency
70
68
  name: configureasy
71
69
  requirement: !ruby/object:Gem::Requirement
72
70
  requirements:
73
- - - ! '>='
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.0'
74
+ - - ">="
74
75
  - !ruby/object:Gem::Version
75
76
  version: 1.0.0
76
77
  type: :runtime
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - ! '>='
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.0'
84
+ - - ">="
81
85
  - !ruby/object:Gem::Version
82
86
  version: 1.0.0
83
- description:
87
+ description: Gem para criação de pacotes deb para distribuição de seus projetos em
88
+ ambientes Debian
84
89
  email:
85
90
  - ajfprates@gmail.com
86
91
  executables:
@@ -88,8 +93,7 @@ executables:
88
93
  extensions: []
89
94
  extra_rdoc_files: []
90
95
  files:
91
- - .gitignore
92
- - .ruby-version
96
+ - ".gitignore"
93
97
  - Gemfile
94
98
  - README.md
95
99
  - Rakefile
@@ -107,9 +111,9 @@ files:
107
111
  - lib/core_ext/hash.rb
108
112
  - templates/.buildable.yml.erb
109
113
  - templates/Procfile.erb
110
- - templates/foreman/master.erb
114
+ - templates/foreman/master.pill.erb
111
115
  - templates/production.env.erb
112
- homepage:
116
+ homepage: https://github.com/r7com/buildable
113
117
  licenses:
114
118
  - MIT
115
119
  metadata: {}
@@ -121,18 +125,18 @@ require_paths:
121
125
  - lib/buildable
122
126
  required_ruby_version: !ruby/object:Gem::Requirement
123
127
  requirements:
124
- - - ! '>='
128
+ - - ">="
125
129
  - !ruby/object:Gem::Version
126
130
  version: '0'
127
131
  required_rubygems_version: !ruby/object:Gem::Requirement
128
132
  requirements:
129
- - - ! '>='
133
+ - - ">="
130
134
  - !ruby/object:Gem::Version
131
135
  version: '0'
132
136
  requirements: []
133
137
  rubyforge_project:
134
- rubygems_version: 2.4.8
138
+ rubygems_version: 2.5.1
135
139
  signing_key:
136
140
  specification_version: 4
137
- summary: Gem para criar pacotes (debian) para deploy de projetos ruby.
141
+ summary: Gem para criação de pacotes deb
138
142
  test_files: []
@@ -1 +0,0 @@
1
- 1.9.3-p448
@@ -1,97 +0,0 @@
1
- #! /bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: <%= app %>
4
- # Required-Start: $remote_fs $syslog
5
- # Required-Stop: $remote_fs $syslog
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Generated initscript for <%= app %>
9
- # Description: This file starts <%= app %>. It should be placed in /etc/init.d
10
- ### END INIT INFO
11
-
12
- # Auto generated by Buildable
13
-
14
- PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
- DESC="Runs <%= app %>"
16
- NAME=<%= app %>
17
- PIDDIR=/var/run/$NAME
18
- SCRIPTNAME=/etc/init.d/$NAME
19
- USERNAME=<%= user %>
20
- <% engine.environment.each_pair do |var,env| %>export <%= var.upcase %>=<%= env %>
21
- <% end %>
22
-
23
- [ -r /lib/lsb/init-functions ] &&. /lib/lsb/init-functions
24
-
25
- #
26
- # Function that starts the service
27
- #
28
- do_start()
29
- {
30
- mkdir -p $PIDDIR
31
- # START APPLICATION: <%= app %><% engine.each_process do |name, process| %>
32
- # START PROCESS: <%= name %><% 1.upto(engine.formation[name]) do |num| %>
33
- # START CONCURRENT: <%= num %>
34
- # Start: <%= app %>.<%= name %>.<%= num %>
35
- # Create $PIDDIR/<%= name %>.<%= num %>.pid
36
- su -m $USERNAME -c 'cd <%= engine.root %>; <%= process.command %> & echo $!' > $PIDDIR/<%= name %>.<%= num %>.pid
37
- <% end %><% end %>
38
- }
39
-
40
- #
41
- # Function that stops the service
42
- #
43
- do_stop()
44
- {
45
- # STOP APPLICATION: <%= app %><% engine.each_process do |name, process| %>
46
- # STOP PROCESS: <%= name %><% 1.upto(engine.formation[name]) do |num| %>
47
- # STOP CONCURRENT: <%= num %>
48
- # Stop: <%= app %>.<%= name %>.<%= num %>
49
- kill `cat $PIDDIR/<%= name %>.<%= num %>.pid`
50
- rm $PIDDIR/<%= name %>.<%= num %>.pid
51
- <% end %><% end %>
52
- rmdir $PIDDIR
53
- }
54
-
55
- case "$1" in
56
- start)
57
- log_daemon_msg "Starting $DESC" "$NAME"
58
- do_start
59
- case "$?" in
60
- 0|1) log_end_msg 0 ;;
61
- 2) log_end_msg 1 ;;
62
- esac
63
- ;;
64
- stop)
65
- log_daemon_msg "Stopping $DESC" "$NAME"
66
- do_stop
67
- case "$?" in
68
- 0|1) log_end_msg 0 ;;
69
- 2) log_end_msg 1 ;;
70
- esac
71
- ;;
72
- status)
73
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
74
- ;;
75
- restart)
76
- log_daemon_msg "Restarting $DESC" "$NAME"
77
- do_stop
78
- case "$?" in
79
- 0|1)
80
- do_start
81
- case "$?" in
82
- 0) log_end_msg 0 ;;
83
- 1) log_end_msg 1 ;; # Old process is still running
84
- *) log_end_msg 1 ;; # Failed to start
85
- esac
86
- ;;
87
- *)
88
- # Failed to stop
89
- log_end_msg 1
90
- ;;
91
- esac
92
- ;;
93
- *)
94
- echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
95
- exit 3
96
- ;;
97
- esac