gemstash 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +33 -0
  3. data/lib/gemstash.rb +2 -0
  4. data/lib/gemstash/api_key_authorization.rb +29 -0
  5. data/lib/gemstash/authorization.rb +5 -1
  6. data/lib/gemstash/cli/authorize.rb +1 -1
  7. data/lib/gemstash/cli/setup.rb +50 -37
  8. data/lib/gemstash/cli/start.rb +1 -1
  9. data/lib/gemstash/config.ru +1 -0
  10. data/lib/gemstash/configuration.rb +35 -3
  11. data/lib/gemstash/db/version.rb +11 -0
  12. data/lib/gemstash/env.rb +16 -10
  13. data/lib/gemstash/gem_fetcher.rb +1 -1
  14. data/lib/gemstash/gem_pusher.rb +15 -17
  15. data/lib/gemstash/gem_source/private_source.rb +29 -44
  16. data/lib/gemstash/gem_source/upstream_source.rb +4 -4
  17. data/lib/gemstash/gem_unyanker.rb +10 -4
  18. data/lib/gemstash/gem_yanker.rb +10 -4
  19. data/lib/gemstash/health.rb +53 -0
  20. data/lib/gemstash/http_client.rb +5 -3
  21. data/lib/gemstash/logging.rb +1 -1
  22. data/lib/gemstash/man/gemstash-authorize.1 +6 -5
  23. data/lib/gemstash/man/gemstash-authorize.1.txt +14 -13
  24. data/lib/gemstash/man/gemstash-configuration.5 +90 -8
  25. data/lib/gemstash/man/gemstash-configuration.5.txt +82 -6
  26. data/lib/gemstash/man/gemstash-customize.7 +68 -12
  27. data/lib/gemstash/man/gemstash-customize.7.txt +64 -26
  28. data/lib/gemstash/man/gemstash-debugging.7 +1 -1
  29. data/lib/gemstash/man/gemstash-deploy.7 +33 -1
  30. data/lib/gemstash/man/gemstash-deploy.7.txt +25 -0
  31. data/lib/gemstash/man/gemstash-mirror.7 +1 -1
  32. data/lib/gemstash/man/gemstash-multiple-sources.7 +1 -1
  33. data/lib/gemstash/man/gemstash-private-gems.7 +52 -3
  34. data/lib/gemstash/man/gemstash-private-gems.7.txt +39 -4
  35. data/lib/gemstash/man/gemstash-readme.7 +34 -4
  36. data/lib/gemstash/man/gemstash-readme.7.txt +34 -12
  37. data/lib/gemstash/man/gemstash-setup.1 +3 -1
  38. data/lib/gemstash/man/gemstash-setup.1.txt +3 -1
  39. data/lib/gemstash/man/gemstash-start.1 +4 -3
  40. data/lib/gemstash/man/gemstash-start.1.txt +5 -4
  41. data/lib/gemstash/man/gemstash-status.1 +4 -3
  42. data/lib/gemstash/man/gemstash-status.1.txt +3 -2
  43. data/lib/gemstash/man/gemstash-stop.1 +4 -3
  44. data/lib/gemstash/man/gemstash-stop.1.txt +3 -2
  45. data/lib/gemstash/man/gemstash-version.1 +1 -1
  46. data/lib/gemstash/puma.rb +2 -2
  47. data/lib/gemstash/specs_builder.rb +14 -16
  48. data/lib/gemstash/version.rb +1 -1
  49. metadata +29 -7
@@ -13,8 +13,15 @@ SYNOPSIS
13
13
  :memcached_servers: localhost:11211
14
14
  :db_adapter: postgres
15
15
  :db_url: postgres:///gemstash
16
+ :db_connection_options:
17
+ :test: true
18
+ :pool_timeout: 2
16
19
  :rubygems_url: https://my.gem-source.local
20
+ :puma_threads: 32
17
21
  :bind: tcp://0.0.0.0:4242
22
+ :protected_fetch: true
23
+ :fetch_timeout: 10
24
+ :log_file: gemstash.log
18
25
 
19
26
  BASE PATH
20
27
  :base_path
@@ -64,21 +71,22 @@ DB ADAPTER
64
71
  Specifies what database adapter to use. When sqlite3 is used, the
65
72
  database will be located at gemstash.db within the directory specified
66
73
  by :base_path. The database will automatically be created when using
67
- sqlite3. When postgres is used, the database to connect to must be
68
- specified in the :db_url configuration key. The database must already
69
- be created when using postgres.
74
+ sqlite3. When postgres, mysql, or mysql2 is used, the database to con-
75
+ nect to must be specified in the :db_url configuration key. The data-
76
+ base must already be created when using anything other than sqlite3.
70
77
 
71
78
  DEFAULT VALUE
72
79
  sqlite3
73
80
 
74
81
  VALID VALUES
75
- sqlite3, postgres
82
+ sqlite3, postgres, mysql, mysql2
76
83
 
77
84
  DB URL
78
85
  :db_url
79
86
 
80
- Specifies the database to connect to when using postgres for the
81
- :db_adapter. Only used when postgres is used for :db_adapter.
87
+ Specifies the database to connect to when using postgres, mysql, or
88
+ mysql2 for the :db_adapter. Only used when the :db_adapter is not
89
+ sqlite3.
82
90
 
83
91
  DEFAULT VALUE
84
92
  None
@@ -87,6 +95,22 @@ DB URL
87
95
  A valid database URL for the Sequel gem (http://sequel.jeremye-
88
96
  vans.net/)
89
97
 
98
+ DB CONNECTION OPTIONS
99
+ :db_connection_options
100
+
101
+ Specifies additional Sequel.connect options to use. Note that any op-
102
+ tions here are merged in with the default options, so you need not
103
+ specify the max_connections if you customize this option.
104
+
105
+ DEFAULT VALUE
106
+ { max_connections: 1 } for sqlite3 adapter, { max_connections: con-
107
+ fig[:puma_threads] + 1 } for any other adapter.
108
+
109
+ VALID VALUES
110
+ A valid connection options Hash for the Sequel.connect (http://se-
111
+ quel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-
112
+ General+connection+options) method.
113
+
90
114
  RUBYGEMS URL
91
115
  :rubygems_url
92
116
 
@@ -101,6 +125,17 @@ RUBYGEMS URL
101
125
  VALID VALUES
102
126
  A valid gem source URL
103
127
 
128
+ PUMA THREADS
129
+ :puma_threads
130
+
131
+ Specifies the number of threads used for the Gemstash server.
132
+
133
+ DEFAULT VALUE
134
+ 16
135
+
136
+ VALID VALUES
137
+ Integer value with a minimum of 1
138
+
104
139
  BIND ADDRESS
105
140
  :bind
106
141
 
@@ -116,6 +151,47 @@ BIND ADDRESS
116
151
  Any valid binding that is supported by Puma
117
152
  (https://github.com/puma/puma#binding-tcp--sockets)
118
153
 
154
+ PROTECTED FETCH
155
+ :protected_fetch
156
+
157
+ Tells Gemstash to authenticate via an API key before allowing the
158
+ fetching of private gems and specs. The default behavior is to allow
159
+ unauthenticated download of private gems and specs.
160
+
161
+ DEFAULT VALUE
162
+ false
163
+
164
+ VALID VALUES
165
+ Boolean values true or false
166
+
167
+ FETCH TIMEOUT
168
+ :fetch_timeout
169
+
170
+ The timeout setting for fetching gems. Fetching gems over a slow con-
171
+ nection may cause timeout errors. If you experience timeout errors,
172
+ you may want to increase this value. The default is 20 seconds.
173
+
174
+ DEFAULT VALUE
175
+ 20
176
+
177
+ VALID VALUES
178
+ Integer value with a minimum of 1
179
+
180
+ LOG FILE
181
+ :log_file
182
+
183
+ Indicates the name of the file to use for logging. The file will be
184
+ placed in the base path (gemstash help configuration.5).
185
+
186
+ DEFAULT VALUE
187
+ server.log
188
+
189
+ VALID VALUES
190
+ Any valid file name, or :stdout to log to $stdout
191
+
192
+ Note: Using :stdout for the :log_file requires running with --no-daemo-
193
+ nize (gemstash help start.1).
194
+
119
195
 
120
196
 
121
197
  October 13, 2015 gemstash-configuration(5)
@@ -1,4 +1,4 @@
1
- .\" Automatically generated by Pandoc 1.16.0.2
1
+ .\" Automatically generated by Pandoc 1.19.2.1
2
2
  .\"
3
3
  .TH "gemstash\-customize" "7" "October 28, 2015" "" ""
4
4
  .hy
@@ -16,7 +16,6 @@ command.
16
16
  Run \f[C]gemstash\ setup\f[] and answer the questions it provides (a
17
17
  blank answer will use the default value):
18
18
  .RS
19
- .PP
20
19
  $ gemstash setup
21
20
  .PD 0
22
21
  .P
@@ -37,7 +36,7 @@ What is the comma separated Memcached servers?
37
36
  .P
38
37
  .PD
39
38
  What database adapter?
40
- [SQLITE3, postgres] \f[B]postgres\f[]
39
+ [SQLITE3, postgres, mysql, mysql2] \f[B]postgres\f[]
41
40
  .PD 0
42
41
  .P
43
42
  .PD
@@ -55,16 +54,18 @@ Checking that the database is available
55
54
  .P
56
55
  .PD
57
56
  The database is not available
57
+ .PD 0
58
+ .P
59
+ .PD
58
60
  .RE
59
61
  .PP
60
- Once you\[aq]ve answered the questsions, some checks will be made to
62
+ Once you\[aq]ve answered the questions, some checks will be made to
61
63
  ensure the configuration will work.
62
64
  For example, the database didn\[aq]t exist in the previous example, so
63
65
  the command failed and the configuration wasn\[aq]t saved.
64
66
  If the command passes, you may provide the \f[C]\-\-redo\f[] option to
65
67
  force configuration to be redone:
66
68
  .RS
67
- .PP
68
69
  $ gemstash setup \-\-redo
69
70
  .PD 0
70
71
  .P
@@ -85,7 +86,7 @@ What is the comma separated Memcached servers?
85
86
  .P
86
87
  .PD
87
88
  What database adapter?
88
- [SQLITE3, postgres]
89
+ [SQLITE3, postgres, mysql, mysql2]
89
90
  .PD 0
90
91
  .P
91
92
  .PD
@@ -98,6 +99,9 @@ Checking that the database is available
98
99
  .P
99
100
  .PD
100
101
  You are all setup!
102
+ .PD 0
103
+ .P
104
+ .PD
101
105
  .RE
102
106
  .PP
103
107
  Once all checks have passed, Gemstash will store your answers in the
@@ -130,10 +134,12 @@ The default \f[C]:db_adapter\f[] is
130
134
  file located within your \f[C]:base_path\f[].
131
135
  The database file will always be named \f[C]gemstash.db\f[].
132
136
  .PP
133
- You may also use \f[C]postgres\f[] (http://www.postgresql.org/) for your
134
- \f[C]:db_adapter\f[].
135
- When using PostgreSQL, you need to specify the \f[C]:db_url\f[] to point
136
- to an existing database.
137
+ You may also use \f[C]postgres\f[] (http://www.postgresql.org/),
138
+ \f[C]mysql\f[] (http://www.mysql.com/), or
139
+ \f[C]mysql2\f[] (http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html#label-mysql2)
140
+ for your \f[C]:db_adapter\f[].
141
+ When using any of these options, you need to specify the
142
+ \f[C]:db_url\f[] to point to an existing database.
137
143
  Here is an example configuration to use the \f[C]postgres\f[] adapter:
138
144
  .IP
139
145
  .nf
@@ -142,13 +148,18 @@ Here is an example configuration to use the \f[C]postgres\f[] adapter:
142
148
  \-\-\-
143
149
  :db_adapter:\ postgres
144
150
  :db_url:\ postgres:///gemstash
151
+ :db_connection_options:\ #\ Sequel.connect\ options
152
+ \ \ :connect_timeout:\ 10
153
+ \ \ :read_timeout:\ 5
154
+ \ \ :timeout:\ 30
145
155
  \f[]
146
156
  .fi
147
157
  .PP
148
158
  Regardless of the adapter you choose, the database will automatically
149
159
  migrate to your version of Gemstash whenever the database is needed.
150
- Except for \f[C]sqlite3\f[], you only need to ensure the database exists
151
- and Gemstash will do the rest.
160
+ You only need to ensure the database exists and Gemstash will do the
161
+ rest, except for \f[C]sqlite3\f[] (for which Gemstash will also create
162
+ the database for you).
152
163
  .SS CACHE
153
164
  .PP
154
165
  Certain things (like dependencies) are cached in memory.
@@ -198,6 +209,36 @@ To change the binding, update the \f[C]:bind\f[] configuration key:
198
209
  This maps directly to the Puma bind
199
210
  flag (https://github.com/puma/puma#binding-tcp--sockets), and will
200
211
  support anything valid for that flag.
212
+ .PP
213
+ The number of threads Puma uses is also customizable via the
214
+ \f[C]:puma_threads\f[] configuration key.
215
+ The default is \f[C]16\f[].
216
+ .SS PROTECTED FETCH
217
+ .PP
218
+ Gemstash by default allows unauthenticated access for private gems.
219
+ Authenticated access is available via the \f[C]:protected_fetch\f[]
220
+ configuration key.
221
+ .IP
222
+ .nf
223
+ \f[C]
224
+ #\ ~/.gemstash/config.yml
225
+ \-\-\-
226
+ :protected_fetch:\ true
227
+ \f[]
228
+ .fi
229
+ .PP
230
+ More details on protected_fetch are here (gemstash help private-gems.7).
231
+ .SS FETCH TIMEOUT
232
+ .PP
233
+ The default fetch timeout is 20 seconds.
234
+ Use the \f[C]:fetch_timeout\f[] configuration key to change it.
235
+ .IP
236
+ .nf
237
+ \f[C]
238
+ \-\-\-
239
+ :fetch_timeout:\ 20
240
+ \f[]
241
+ .fi
201
242
  .SS CONFIG FILE LOCATION
202
243
  .PP
203
244
  By default, configuration for Gemstash will be at
@@ -222,3 +263,18 @@ If the file doesn\[aq]t exist when providing \f[C]\-\-config\-file\f[]
222
263
  to \f[C]gemstash\ start\f[], \f[C]gemstash\ stop\f[],
223
264
  \f[C]gemstash\ status\f[], and \f[C]gemstash\ authorize\f[], the default
224
265
  configuration will be used.
266
+ .SS ERB PARSED CONFIG
267
+ .PP
268
+ You may also create a \f[C]~/.gemstash/config.yml.erb\f[] file.
269
+ If present, this will be used instead of
270
+ \f[C]~/.gemstash/config.yml\f[].
271
+ For example, with this you can use environment variables in the config:
272
+ .IP
273
+ .nf
274
+ \f[C]
275
+ #\ ~/.gemstash/config.yml.erb
276
+ \-\-\-
277
+ :db_adapter:\ postgres
278
+ :db_url:\ <%=\ ENV["DATABASE_URL"]\ %>
279
+ \f[]
280
+ .fi
@@ -13,35 +13,34 @@ CUSTOMIZING THE SERVER
13
13
  Several customizable options are available via an interactive Gemstash
14
14
  command. Run gemstash setup and answer the questions it provides (a
15
15
  blank answer will use the default value):
16
-
17
16
  $ gemstash setup
18
17
  Where should files go? [~/.gemstash]
19
18
  Cache with what? [MEMORY, memcached] memcached
20
19
  What is the comma separated Memcached servers? [local-
21
20
  host:11211]
22
- What database adapter? [SQLITE3, postgres] postgres
21
+ What database adapter? [SQLITE3, postgres, mysql, mysql2] post-
22
+ gres
23
23
  Where is the database? [postgres:///gemstash]
24
24
  Checking that the cache is available
25
25
  Checking that the database is available
26
26
  The database is not available
27
27
 
28
- Once you've answered the questsions, some checks will be made to ensure
28
+ Once you've answered the questions, some checks will be made to ensure
29
29
  the configuration will work. For example, the database didn't exist in
30
- the previous example, so the command failed and the configuration
30
+ the previous example, so the command failed and the configuration
31
31
  wasn't saved. If the command passes, you may provide the --redo option
32
32
  to force configuration to be redone:
33
-
34
33
  $ gemstash setup --redo
35
34
  Where should files go? [~/.gemstash]
36
35
  Cache with what? [MEMORY, memcached] memcached
37
- What is the comma separated Memcached servers? [local-
36
+ What is the comma separated Memcached servers? [local-
38
37
  host:11211]
39
- What database adapter? [SQLITE3, postgres]
38
+ What database adapter? [SQLITE3, postgres, mysql, mysql2]
40
39
  Checking that the cache is available
41
40
  Checking that the database is available
42
41
  You are all setup!
43
42
 
44
- Once all checks have passed, Gemstash will store your answers in the
43
+ Once all checks have passed, Gemstash will store your answers in the
45
44
  configuration file located at ~/.gemstash/config.yml.
46
45
 
47
46
  FILES
@@ -52,31 +51,38 @@ CUSTOMIZING THE SERVER
52
51
  ---
53
52
  :base_path: "/var/gemstash"
54
53
 
55
- When customizing the base_path, the directory must exist, otherwise
54
+ When customizing the base_path, the directory must exist, otherwise
56
55
  Gemstash will fail to run. Thus, if you want to use /var/gemstash like
57
56
  in the previous example, make sure to mkdir /var/gemstash and grant ac-
58
57
  cess to the directory for the user you run Gemstash with.
59
58
 
60
59
  DATABASE
61
- The :db_adapter configuration key specifies what database you will be
62
- using. The default :db_adapter is sqlite3 (https://www.sqlite.org/),
63
- which will use a database file located within your :base_path. The
60
+ The :db_adapter configuration key specifies what database you will be
61
+ using. The default :db_adapter is sqlite3 (https://www.sqlite.org/),
62
+ which will use a database file located within your :base_path. The
64
63
  database file will always be named gemstash.db.
65
64
 
66
- You may also use postgres (http://www.postgresql.org/) for your
67
- :db_adapter. When using PostgreSQL, you need to specify the :db_url to
68
- point to an existing database. Here is an example configuration to use
69
- the postgres adapter:
65
+ You may also use postgres (http://www.postgresql.org/), mysql
66
+ (http://www.mysql.com/), or mysql2 (http://sequel.jeremye-
67
+ vans.net/rdoc/files/doc/opening_databases_rdoc.html#label-mysql2) for
68
+ your :db_adapter. When using any of these options, you need to specify
69
+ the :db_url to point to an existing database. Here is an example con-
70
+ figuration to use the postgres adapter:
70
71
 
71
72
  # ~/.gemstash/config.yml
72
73
  ---
73
74
  :db_adapter: postgres
74
75
  :db_url: postgres:///gemstash
76
+ :db_connection_options: # Sequel.connect options
77
+ :connect_timeout: 10
78
+ :read_timeout: 5
79
+ :timeout: 30
75
80
 
76
- Regardless of the adapter you choose, the database will automatically
77
- migrate to your version of Gemstash whenever the database is needed.
78
- Except for sqlite3, you only need to ensure the database exists and
79
- Gemstash will do the rest.
81
+ Regardless of the adapter you choose, the database will automatically
82
+ migrate to your version of Gemstash whenever the database is needed.
83
+ You only need to ensure the database exists and Gemstash will do the
84
+ rest, except for sqlite3 (for which Gemstash will also create the data-
85
+ base for you).
80
86
 
81
87
  CACHE
82
88
  Certain things (like dependencies) are cached in memory. This avoids
@@ -115,9 +121,31 @@ CUSTOMIZING THE SERVER
115
121
  (https://github.com/puma/puma#binding-tcp--sockets), and will support
116
122
  anything valid for that flag.
117
123
 
124
+ The number of threads Puma uses is also customizable via the
125
+ :puma_threads configuration key. The default is 16.
126
+
127
+ PROTECTED FETCH
128
+ Gemstash by default allows unauthenticated access for private gems.
129
+ Authenticated access is available via the :protected_fetch configura-
130
+ tion key.
131
+
132
+ # ~/.gemstash/config.yml
133
+ ---
134
+ :protected_fetch: true
135
+
136
+ More details on protected_fetch are here (gemstash help private-
137
+ gems.7).
138
+
139
+ FETCH TIMEOUT
140
+ The default fetch timeout is 20 seconds. Use the :fetch_timeout con-
141
+ figuration key to change it.
142
+
143
+ ---
144
+ :fetch_timeout: 20
145
+
118
146
  CONFIG FILE LOCATION
119
- By default, configuration for Gemstash will be at ~/.gemstash/con-
120
- fig.yml. This can be changed by providing the --config-file option to
147
+ By default, configuration for Gemstash will be at ~/.gemstash/con-
148
+ fig.yml. This can be changed by providing the --config-file option to
121
149
  the various Gemstash commands:
122
150
 
123
151
  $ gemstash setup --config-file ./gemstash-config.yml
@@ -126,12 +154,22 @@ CUSTOMIZING THE SERVER
126
154
  $ gemstash stop --config-file ./gemstash-config.yml
127
155
  $ gemstash status --config-file ./gemstash-config.yml
128
156
 
129
- When providing --config-file to gemstash setup, the provided file will
130
- be output to with the provided configuration. This will overwrite any
131
- existing configuration. If the file doesn't exist when providing
132
- --config-file to gemstash start, gemstash stop, gemstash status, and
157
+ When providing --config-file to gemstash setup, the provided file will
158
+ be output to with the provided configuration. This will overwrite any
159
+ existing configuration. If the file doesn't exist when providing
160
+ --config-file to gemstash start, gemstash stop, gemstash status, and
133
161
  gemstash authorize, the default configuration will be used.
134
162
 
163
+ ERB PARSED CONFIG
164
+ You may also create a ~/.gemstash/config.yml.erb file. If present,
165
+ this will be used instead of ~/.gemstash/config.yml. For example, with
166
+ this you can use environment variables in the config:
167
+
168
+ # ~/.gemstash/config.yml.erb
169
+ ---
170
+ :db_adapter: postgres
171
+ :db_url: <%= ENV["DATABASE_URL"] %>
172
+
135
173
 
136
174
 
137
175
  October 28, 2015 gemstash-customize(7)
@@ -1,4 +1,4 @@
1
- .\" Automatically generated by Pandoc 1.16.0.2
1
+ .\" Automatically generated by Pandoc 1.19.2.1
2
2
  .\"
3
3
  .TH "gemstash\-debugging" "7" "October 28, 2015" "" ""
4
4
  .hy
@@ -1,4 +1,4 @@
1
- .\" Automatically generated by Pandoc 1.16.0.2
1
+ .\" Automatically generated by Pandoc 1.19.2.1
2
2
  .\"
3
3
  .TH "gemstash\-deploy" "7" "October 25, 2015" "" ""
4
4
  .hy
@@ -34,6 +34,38 @@ $\ bundle\ update
34
34
  $\ bundle\ exec\ gemstash\ start
35
35
  \f[]
36
36
  .fi
37
+ .SS MONITORING
38
+ .PP
39
+ Health monitoring is built in to Gemstash using the
40
+ server_health_check\-rack (https://github.com/on-site/server_health_check-rack)
41
+ gem.
42
+ If you request \f[C]/health\f[] from your Gemstash instance, you will
43
+ get a JSON response along with an HTTP status code indicating success or
44
+ failure.
45
+ The JSON response will look something like this for a success case:
46
+ .IP
47
+ .nf
48
+ \f[C]
49
+ {
50
+ \ \ "status":\ {
51
+ \ \ \ \ "heartbeat":\ "OK",
52
+ \ \ \ \ "storage_read":\ "OK",
53
+ \ \ \ \ "storage_write":\ "OK",
54
+ \ \ \ \ "db_read":\ "OK",
55
+ \ \ \ \ "db_write":\ "OK"
56
+ \ \ }
57
+ }
58
+ \f[]
59
+ .fi
60
+ .PP
61
+ This request will test storage and database access and report on the
62
+ result.
63
+ Each key in the status can be requested alone to just report on that
64
+ status.
65
+ For example, if you would like a health check that doesn\[aq]t interact
66
+ with storage or the database, you can use \f[C]/health/heartbeat\f[]
67
+ which will always respond with a success while your Gemstash server is
68
+ running.
37
69
  .SS DOWNGRADING
38
70
  .PP
39
71
  It is not recommended to go backwards in Gemstash versions.