mina 0.3.8 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +16 -0
  3. data/.gitignore +0 -1
  4. data/.rubocop.yml +1156 -0
  5. data/Gemfile +2 -8
  6. data/{CHANGELOG.md → PRE_1_CHANGELOG.md} +0 -0
  7. data/Rakefile +2 -18
  8. data/Readme.md +39 -1116
  9. data/bin/mina +1 -62
  10. data/data/deploy.rb +19 -46
  11. data/data/deploy.sh.erb +22 -23
  12. data/docs/Readme.md +8 -0
  13. data/docs/command_line_options.md +33 -0
  14. data/docs/deploying.md +97 -0
  15. data/docs/faq.md +1 -0
  16. data/docs/getting_started.md +44 -0
  17. data/docs/migrating.md +30 -0
  18. data/docs/writing_your_own_tasks.md +117 -0
  19. data/lib/Minafile +3 -0
  20. data/lib/mina.rb +30 -18
  21. data/lib/mina/application.rb +74 -0
  22. data/lib/mina/backend/local.rb +22 -0
  23. data/lib/mina/backend/remote.rb +42 -0
  24. data/lib/mina/commands.rb +45 -0
  25. data/lib/mina/configuration.rb +36 -0
  26. data/lib/mina/dsl.rb +47 -0
  27. data/lib/mina/helpers/internal.rb +29 -0
  28. data/lib/mina/helpers/output.rb +42 -0
  29. data/lib/mina/runner.rb +39 -0
  30. data/lib/mina/runner/exec.rb +15 -0
  31. data/lib/mina/runner/pretty.rb +53 -0
  32. data/lib/mina/runner/printer.rb +17 -0
  33. data/lib/mina/runner/system.rb +15 -0
  34. data/lib/mina/version.rb +1 -3
  35. data/mina.gemspec +27 -16
  36. data/spec/lib/mina/application_spec.rb +39 -0
  37. data/spec/lib/mina/backend/local_spec.rb +16 -0
  38. data/spec/lib/mina/backend/remote_spec.rb +17 -0
  39. data/spec/lib/mina/commands_spec.rb +93 -0
  40. data/spec/lib/mina/configuration_spec.rb +52 -0
  41. data/spec/lib/mina/helpers/internal_spec.rb +50 -0
  42. data/spec/lib/mina/helpers/output_spec.rb +48 -0
  43. data/spec/lib/mina/runner_spec.rb +36 -0
  44. data/spec/lib/mina_spec.rb +7 -0
  45. data/spec/spec_helper.rb +13 -21
  46. data/spec/support/run_helper.rb +36 -0
  47. data/tasks/mina/bundler.rb +15 -0
  48. data/tasks/mina/chruby.rb +19 -0
  49. data/tasks/mina/default.rb +36 -0
  50. data/tasks/mina/deploy.rb +85 -0
  51. data/tasks/mina/git.rb +36 -0
  52. data/tasks/mina/install.rb +18 -0
  53. data/tasks/mina/rails.rb +108 -0
  54. data/tasks/mina/rbenv.rb +15 -0
  55. data/tasks/mina/rvm.rb +39 -0
  56. data/tasks/mina/ry.rb +26 -0
  57. data/test_env/config/deploy.rb +44 -72
  58. metadata +82 -59
  59. data/.travis.yml +0 -21
  60. data/CONTRIBUTING.md +0 -124
  61. data/HISTORY.md +0 -394
  62. data/Makefile +0 -32
  63. data/Notes.md +0 -70
  64. data/lib/mina/bundler.rb +0 -49
  65. data/lib/mina/chruby.rb +0 -49
  66. data/lib/mina/default.rb +0 -158
  67. data/lib/mina/deploy.rb +0 -160
  68. data/lib/mina/deploy_helpers.rb +0 -34
  69. data/lib/mina/exec_helpers.rb +0 -111
  70. data/lib/mina/foreman.rb +0 -83
  71. data/lib/mina/git.rb +0 -69
  72. data/lib/mina/helpers.rb +0 -408
  73. data/lib/mina/local_helpers.rb +0 -97
  74. data/lib/mina/npm.rb +0 -89
  75. data/lib/mina/output_helpers.rb +0 -92
  76. data/lib/mina/rails.rb +0 -245
  77. data/lib/mina/rake.rb +0 -10
  78. data/lib/mina/rbenv.rb +0 -47
  79. data/lib/mina/rvm.rb +0 -88
  80. data/lib/mina/ry.rb +0 -55
  81. data/lib/mina/settings.rb +0 -32
  82. data/lib/mina/ssh_helpers.rb +0 -125
  83. data/lib/mina/tools.rb +0 -20
  84. data/lib/mina/whenever.rb +0 -51
  85. data/manual/index.md +0 -15
  86. data/manual/modules.md +0 -2
  87. data/spec/command_helper.rb +0 -52
  88. data/spec/commands/cleanup_spec.rb +0 -16
  89. data/spec/commands/command_spec.rb +0 -71
  90. data/spec/commands/custom_config_spec.rb +0 -20
  91. data/spec/commands/deploy_spec.rb +0 -40
  92. data/spec/commands/outside_project_spec.rb +0 -35
  93. data/spec/commands/real_deploy_spec.rb +0 -56
  94. data/spec/commands/ssh_spec.rb +0 -14
  95. data/spec/commands/verbose_spec.rb +0 -21
  96. data/spec/dsl/invoke_spec.rb +0 -49
  97. data/spec/dsl/queue_spec.rb +0 -49
  98. data/spec/dsl/settings_in_rake_spec.rb +0 -39
  99. data/spec/dsl/settings_spec.rb +0 -61
  100. data/spec/dsl/to_spec.rb +0 -20
  101. data/spec/fixtures/custom_file_env/custom_deploy.rb +0 -15
  102. data/spec/fixtures/empty_env/config/deploy.rb +0 -15
  103. data/spec/helpers/exec_helper_spec.rb +0 -19
  104. data/spec/helpers/local_helper_spec.rb +0 -70
  105. data/spec/helpers/output_helper_spec.rb +0 -38
  106. data/support/Readme-footer.md +0 -31
  107. data/support/Readme-header.md +0 -16
  108. data/support/guide.md +0 -297
  109. data/support/index.html +0 -53
  110. data/support/third_party_modules.md +0 -23
  111. data/support/to_md.rb +0 -11
data/Gemfile CHANGED
@@ -1,10 +1,4 @@
1
- # Why use bundler?
2
- # Well, not all development dependencies install on all rubies. Moreover, `gem
3
- # install mina --development` doesn't work, as it will also try to install
4
- # development dependencies of our dependencies, and those are not conflict free.
5
- # So, here we are, `bundle install`.
1
+ source 'https://rubygems.org'
6
2
 
7
- source "https://rubygems.org"
3
+ # Specify your gem's dependencies in capistrano.gemspec
8
4
  gemspec
9
-
10
- gem 'rake', "~> #{ENV['rake'] || "0.9"}.0"
File without changes
data/Rakefile CHANGED
@@ -1,20 +1,4 @@
1
- require 'bundler'
2
1
  require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- github = ENV['github'] || 'nadarei/mina'
5
-
6
- task :spec do
7
- system "rm Gemfile.lock; sh -c 'rake=0.8 bundle exec rspec'"
8
- system "rm Gemfile.lock; sh -c 'rake=0.9 bundle exec rspec'"
9
- end
10
-
11
- task :docs do
12
- files = ['manual/index.md', 'manual/modules.md', 'HISTORY.md'] + Dir['lib/**/*.rb']
13
- system "lidoc #{files.join ' '} -o docs --github #{github}"
14
- end
15
-
16
- task :'docs:deploy' => :docs do
17
- system "git-update-ghpages #{github} -i docs -p docs"
18
- end
19
-
20
- task :default => :spec
4
+ task default: :spec
data/Readme.md CHANGED
@@ -1,1141 +1,59 @@
1
1
  # Mina
2
2
 
3
+ [![Code Climate](https://codeclimate.com/repos/5774207165982076ca005984/badges/6877153919d603250738/gpa.svg)](https://codeclimate.com/repos/5774207165982076ca005984/feed)
4
+ [![Test Coverage](https://codeclimate.com/repos/5774207165982076ca005984/badges/6877153919d603250738/coverage.svg)](https://codeclimate.com/repos/5774207165982076ca005984/coverage)
5
+ [![Build Status](https://semaphoreci.com/api/v1/d4be4st/mina/branches/master/shields_badge.svg)](https://semaphoreci.com/d4be4st/mina)
6
+ [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina)
7
+
3
8
  Really fast deployer and server automation tool.
4
9
 
10
+ ## Warning
11
+
12
+ **This is a readme of the current master, version 1.0.0.beta1. If you are using older mina (pre 0.3) please take a look at [0.3 readme](https://github.com/mina-deploy/mina/blob/v0.3.8/Readme.md)**
13
+
14
+
5
15
  Mina works really fast because it's a deploy Bash script generator. It
6
16
  generates an entire procedure as a Bash script and runs it remotely in the
7
17
  server.
8
18
 
9
- Compare this to the likes of Vlad or Capistrano, where each command
19
+ Compare this to the likes of [Vlad](https://github.com/seattlerb/vlad) or
20
+ [Capistrano](https://github.com/capistrano/capistrano), where each command
10
21
  is run separately on their own SSH sessions. Mina only creates *one* SSH
11
22
  session per deploy, minimizing the SSH connection overhead.
12
23
 
13
24
  $ gem install mina
14
25
  $ mina
15
26
 
16
- [![Build Status](https://travis-ci.org/mina-deploy/mina.svg?branch=master)](https://travis-ci.org/mina-deploy/mina) [![Gem Version](https://badge.fury.io/rb/mina.svg)](http://badge.fury.io/rb/mina) [![Inline docs](http://inch-ci.org/github/mina-deploy/mina.svg?branch=master)](http://inch-ci.org/github/mina-deploy/mina)
17
-
18
- User guide
19
- ==========
20
-
21
- Setting up a project
22
- --------------------
23
-
24
- Let's deploy a project using Mina.
25
-
26
- ### Step 1: Create a config/deploy.rb
27
-
28
- In your project, type `mina init` to create a sample of this file.
29
-
30
- $ mina init
31
- Created config/deploy.rb.
32
-
33
- This is just a Rake file with tasks! See [About deploy.rb](#about-deployrb) for
34
- more info on what *deploy.rb* is. You will want to at least configure your
35
- server:
36
-
37
- ~~~ ruby
38
- # config/deploy.rb
39
- set :user, 'username'
40
- set :domain, 'your.server.com'
41
- set :deploy_to, '/var/www/flipstack.com'
42
- ...
43
- ~~~
44
-
45
- ### Step 2: Set up your server
46
-
47
- Make a directory in your server called `/var/www/flipstack.com` (in *deploy_to*)
48
- change it's ownership to the correct user.
49
-
50
- $ ssh username@your.server.com
51
-
52
- # Once in your server, create the deploy folder:
53
- ~@your.server.com$ mkdir /var/www/flipstack.com
54
- ~@your.server.com$ chown -R username /var/www/flipstack.com
55
-
56
- ### Step 3: Run 'mina setup'
57
-
58
- Back at your computer, do `mina setup` to set up the [folder
59
- structure](#directory_structure) in this path. This will connect to your server
60
- via SSH and create the right directories.
61
-
62
- $ mina setup
63
- -----> Creating folders... done.
64
-
65
- See [directory structure](#directory_structure) for more info.
66
-
67
- ### Step 4: Deploy!
68
-
69
- Use `mina deploy` to run the `deploy` task defined in *config/deploy.rb*.
70
-
71
- $ mina deploy
72
- -----> Deploying to 2012-06-12-040248
73
- ...
74
- Lots of things happening...
75
- ...
76
- -----> Done.
77
-
78
- About deploy.rb
79
- ---------------
80
-
81
- The file `deploy.rb` is simply a Rakefile invoked by Rake. In fact, `mina` is
82
- mostly an alias that invokes Rake to load `deploy.rb`.
83
-
84
- ~~~ ruby
85
- # Sample config/deploy.rb
86
- set :domain, 'your.server.com'
87
-
88
- task :restart do
89
- queue 'sudo service restart apache'
90
- end
91
- ~~~
92
-
93
- As it's all Rake, you can define tasks that you can invoke using `mina`. In this
94
- example, it provides the `mina restart` command.
95
-
96
- The magic of Mina is in the new commands it gives you.
97
-
98
- The `queue` command queues up Bash commands to be run on the remote server.
99
- If you invoke `mina restart`, it will invoke the task above and run the queued
100
- commands on the remote server `your.server.com` via SSH.
101
-
102
- See [the command queue](#the-command-queue) for more information on the *queue*
103
- command.
104
-
105
- The command queue
106
- -----------------
107
-
108
- At the heart of it, Mina is merely sugar on top of Rake to queue commands
109
- and execute them remotely at the end. Take a look at this minimal *deploy.rb*
110
- configuration:
111
-
112
- ~~~ ruby
113
- # config/deploy.rb
114
- set :user, 'john'
115
- set :domain, 'flipstack.com'
116
-
117
- task :logs do
118
- queue 'echo "Contents of the log file are as follows:"'
119
- queue "tail -f /var/log/apache.log"
120
- end
121
- ~~~
122
-
123
- Once you type `mina logs` in your terminal, it invokes the *queue*d commands
124
- remotely on the server using the command `ssh john@flipstack.com`.
125
-
126
- ~~~ sh
127
- $ mina logs --simulate
128
- # Execute the following commands via
129
- # ssh john@flipstack.com:
130
- #
131
- echo "Contents of the log file are as follows:"
132
- tail -f /var/log/apache.log
133
- ~~~
134
-
135
- Subtasks
136
- --------
137
-
138
- Mina provides the helper `invoke` to invoke other tasks from a
139
- task.
140
-
141
- ~~~ ruby
142
- # config/deploy.rb
143
- task :down do
144
- invoke :maintenance_on
145
- invoke :restart
146
- end
147
-
148
- task :maintenance_on
149
- queue 'touch maintenance.txt'
150
- end
151
-
152
- task :restart
153
- queue 'sudo service restart apache'
154
- end
155
- ~~~
156
-
157
- In this example above, if you type `mina down`, it simply invokes the other
158
- subtasks which queues up their commands. The commands will be run after
159
- everything.
160
-
161
- Directory structure
162
- -------------------
163
-
164
- The deploy procedures make the assumption that you have a folder like so:
165
-
166
- /var/www/flipstack.com/ # The deploy_to path
167
- |- releases/ # Holds releases, one subdir per release
168
- | |- 1/
169
- | |- 2/
170
- | |- 3/
171
- | '- ...
172
- |- shared/ # Holds files shared between releases
173
- | |- logs/ # Log files are usually stored here
174
- | `- ...
175
- '- current/ # A symlink to the current release in releases/
176
-
177
- It also assumes that the `deploy_to` path is fully writeable/readable for the
178
- user we're going to SSH with.
179
-
180
- Deploying
181
- ---------
182
-
183
- Mina provides the `deploy` command which *queue*s up a deploy script for
184
- you.
185
-
186
- ~~~ ruby
187
- # config/deploy.rb
188
- set :domain, 'flipstack.com'
189
- set :user, 'flipstack'
190
- set :deploy_to, '/var/www/flipstack.com'
191
- set :repository, 'http://github.com/flipstack/flipstack.git'
192
-
193
- task :deploy do
194
- deploy do
195
- # Put things that prepare the empty release folder here.
196
- # Commands queued here will be run on a new release directory.
197
- invoke :'git:clone'
198
- invoke :'bundle:install'
199
-
200
- # These are instructions to start the app after it's been prepared.
201
- to :launch do
202
- queue 'touch tmp/restart.txt'
203
- end
204
-
205
- # This optional block defines how a broken release should be cleaned up.
206
- to :clean do
207
- queue 'log "failed deployment"'
208
- end
209
- end
210
- end
211
- ~~~
212
-
213
- It works by capturing the *queue*d commands inside the block, wrapping them
214
- in a deploy script, then *queue*ing them back in.
215
-
216
- ### How deploying works
217
-
218
- Here is an example of a deploy! (Note that some commands have been simplified
219
- to illustrate the point better.)
220
-
221
- ### Step 1: Build it
222
-
223
- The deploy process builds a new temp folder with instructions you provide.
224
- In this example, it will do `git:clone` and `bundle:install`.
225
-
226
- $ mina deploy --verbose
227
- -----> Creating the build path
228
- $ mkdir tmp/build-128293482394
229
- -----> Cloning the Git repository
230
- $ git clone https://github.com/flipstack/flipstack.git . -n --recursive
231
- Cloning... done.
232
- -----> Installing gem dependencies using Bundler
233
- $ bundle install --without development:test
234
- Using i18n (0.6.0)
235
- Using multi_json (1.0.4)
236
- ...
237
- Your bundle is complete! It was installed to ./vendor/bundle
238
-
239
- ### Step 2: Move it to releases
240
-
241
- Once the project has been built, it will be moved to `releases/`. A symlink
242
- called `current/` will be created to point to the active release.
243
-
244
- $
245
- -----> Moving to releases/4
246
- $ mv "./tmp/build-128293482394" "releases/4"
247
- -----> Symlinking to current
248
- $ ln -nfs releases/4 current
249
-
250
- ### Step 3: Launch it
251
-
252
- Invoke the commands queued up in the `to :launch` block. These often
253
- commands to restart the webserver process. Once this in complete, you're done!
254
-
255
- $
256
- -----> Launching
257
- $ cd releases/4
258
- $ sudo service nginx restart
259
- -----> Done. Deployed v4
260
-
261
- ### What about failure?
262
-
263
- If it fails at any point, the release path will be deleted. If any commands are
264
- queued using the `to :clean` block, they will be run. It will be as if nothing
265
- happened. Lets see what happens if a build fails:
266
-
267
- $
268
- -----> Launching
269
- $ cd releases/4
270
- $ sudo service nginx restart
271
- Starting nginx... error: can't start service
272
- -----> ERROR: Deploy failed.
273
- -----> Cleaning up build
274
- $ rm -rf tmp/build-128293482394
275
- -----> Unlinking current
276
- $ ln -nfs releases/3 current
277
- OK
278
-
279
- Command line options
280
- --------------------
281
-
282
- Basic usage:
283
-
284
- $ mina [OPTIONS] [TASKS] [VAR1=val VAR2=val ...]
285
-
286
- ### Options
287
-
288
- * `-v` / `--verbose` - This will show commands being done on the server. Off by
289
- default.
290
-
291
- * `-S` / `--simulate` - This will not invoke any SSH connections; instead, it
292
- will simply output the script it builds.
293
-
294
- * `-t` / `--trace` - Show backtraces when errors occur.
295
-
296
- * `-f FILE` - Use a custom deploy.rb configuration.
297
-
298
- * `-V` / `--version` - Shows the current version.
299
-
300
- ### Tasks
301
-
302
- There are many tasks available. See the [tasks reference](http://mina-deploy.github.io/mina/tasks/), or
303
- type `mina tasks`.
304
-
305
- ### Variables
306
-
307
- You may specify additional variables in the `KEY=value` style, just like Rake.
308
- You can add as many variables as needed.
309
-
310
- $ mina restart on=staging
311
-
312
- # This sets the ENV['on'] variable to 'staging'.
313
-
314
-
315
- # Helpers
316
-
317
- ### invoke
318
- Invokes another Rake task.
319
- By default if the task has already been invoked it will not been executed again (see the `:reenable` option).
320
-
321
- Invokes the task given in `task`. Returns nothing.
322
-
323
- ~~~ ruby
324
- invoke :'git:clone'
325
- invoke :restart
326
- ~~~
327
-
328
- Options:
329
- reenable (bool) - Execute the task even next time.
330
-
331
- task.to_s is a ruby 1.8.7 fix
332
-
333
- ### erb
334
- Evaluates an ERB block in the current scope and returns a string.
335
-
336
- ~~~ ruby
337
- a = 1
338
- b = 2
339
- # Assuming foo.erb is <%= a %> and <%= b %>
340
- puts erb('foo.erb')
341
- #=> "1 and 2"
342
- ~~~
343
-
344
- Returns the output string of the ERB template.
345
-
346
- ### run!
347
- SSHs into the host and runs the code that has been queued.
348
-
349
- This is already automatically invoked before Rake exits to run all
350
- commands that have been queued up.
351
-
352
- ~~~ ruby
353
- queue "sudo restart"
354
- run!
355
- ~~~
356
-
357
- Returns nothing.
358
-
359
- ### run_local!
360
- runs the code locally that has been queued.
361
- Has to be in :before_hook or :after_hook queue
362
-
363
- This is already automatically invoked before Rake exits to run all
364
- commands that have been queued up.
365
-
366
- ~~~ ruby
367
- to :before_hook do
368
- queue "cp file1 file2"
369
- end
370
- run_local!(:before_hook)
371
- ~~~
372
-
373
- Returns nothing.
374
-
375
- ### report_time
376
- Report time elapsed in the block.
377
- Returns the output of the block.
378
-
379
- ~~~ ruby
380
- report_time do
381
- sleep 2
382
- # do other things
383
- end
384
- # Output:
385
- # Elapsed time: 2.00 seconds
386
- ~~~
387
-
388
- ### measure
389
- Measures the time (in seconds) a block takes.
390
- Returns a [time, output] tuple.
391
-
392
- ### mina_cleanup
393
- __Internal:__ Invoked when Rake exits.
394
-
395
- Returns nothing.
396
-
397
- ## Errors
398
-
399
- ### die
400
- Exits with a nice looking message.
401
- Returns nothing.
402
-
403
- ~~~ ruby
404
- die 2
405
- die 2, "Tests failed"
406
- ~~~
407
-
408
- ### error
409
- __Internal:__ Prints to stdout.
410
- Consider using `print_error` instead.
411
-
412
- ## Queueing
413
-
414
- ### queue
415
- Queues code to be run.
416
-
417
- This queues code to be run to the current code bucket (defaults to `:default`).
418
- To get the things that have been queued, use commands[:default]
419
-
420
- Returns nothing.
421
-
422
- ~~~ ruby
423
- queue "sudo restart"
424
- queue "true"
425
- commands == ['sudo restart', 'true']
426
- ~~~
427
-
428
- ### queue!
429
- Shortcut for `queue`ing a command that shows up in verbose mode.
430
-
431
- ### echo_cmd
432
- Converts a bash command to a command that echoes before execution.
433
- Used to show commands in verbose mode. This does nothing unless verbose mode is on.
434
-
435
- Returns a string of the compound bash command, typically in the format of
436
- `echo xx && xx`. However, if `verbose_mode?` is false, it returns the
437
- input string unharmed.
438
-
439
- ~~~ ruby
440
- echo_cmd("ln -nfs releases/2 current")
441
- #=> echo "$ ln -nfs releases/2 current" && ln -nfs releases/2 current
442
- ~~~
443
-
444
- ## Commands
445
-
446
- ### commands
447
- Returns an array of queued code strings.
448
-
449
- You may give an optional `aspect`.
450
-
451
- Returns an array of strings.
452
-
453
- ~~~ ruby
454
- queue "sudo restart"
455
- queue "true"
456
- to :clean do
457
- queue "rm"
458
- end
459
- commands == ["sudo restart", "true"]
460
- commands(:clean) == ["rm"]
461
- ~~~
462
-
463
- ### isolate
464
- Starts a new block where new `commands` are collected.
465
-
466
- Returns nothing.
467
-
468
- ~~~ ruby
469
- queue "sudo restart"
470
- queue "true"
471
- commands.should == ['sudo restart', 'true']
472
- isolate do
473
- queue "reload"
474
- commands.should == ['reload']
475
- end
476
- commands.should == ['sudo restart', 'true']
477
- ~~~
478
-
479
- ### in_directory
480
- Starts a new block where #commands are collected, to be executed inside `path`.
481
-
482
- Returns nothing.
483
-
484
- ~~~ ruby
485
- in_directory './webapp' do
486
- queue "./reload"
487
- end
488
- commands.should == ['cd ./webapp && (./reload && true)']
489
- ~~~
490
-
491
- ### to
492
- Defines instructions on how to do a certain thing.
493
- This makes the commands that are `queue`d go into a different bucket in commands.
494
-
495
- Returns nothing.
496
-
497
- ~~~ ruby
498
- to :prepare do
499
- run "bundle install"
500
- end
501
- to :launch do
502
- run "nginx -s restart"
503
- end
504
- commands(:prepare) == ["bundle install"]
505
- commands(:restart) == ["nginx -s restart"]
506
- ~~~
507
-
508
- ## Settings helpers
509
-
510
- ### set
511
- Sets settings.
512
- Sets given symbol `key` to value in `value`.
513
-
514
- Returns the value.
515
-
516
- ~~~ ruby
517
- set :domain, 'kickflip.me'
518
- ~~~
519
-
520
- ### set_default
521
- Sets default settings.
522
- Sets given symbol `key` to value in `value` only if the key isn't set yet.
523
-
524
- Returns the value.
525
-
526
- ~~~ ruby
527
- set_default :term_mode, :pretty
528
- set :term_mode, :system
529
- settings.term_mode.should == :system
530
- set :term_mode, :system
531
- set_default :term_mode, :pretty
532
- settings.term_mode.should == :system
533
- ~~~
534
-
535
- ### settings
536
- Accesses the settings hash.
537
-
538
- ~~~ ruby
539
- set :domain, 'kickflip.me'
540
- settings.domain #=> 'kickflip.me'
541
- domain #=> 'kickflip.me'
542
- ~~~
543
-
544
- ### method_missing
545
- Hook to get settings.
546
- See #settings for an explanation.
547
-
548
- Returns things.
549
-
550
- ## Command line mode helpers
551
-
552
- ### verbose_mode?
553
- Checks if Rake was invoked with --verbose.
554
-
555
- Returns true or false.
556
-
557
- ~~~ ruby
558
- if verbose_mode?
559
- queue %[echo "-----> Starting a new process"]
560
- end
561
- ~~~
562
-
563
- ### simulate_mode?
564
- Checks if Rake was invoked with --simulate.
565
-
566
- Returns true or false.
567
-
568
- ## Internal helpers
569
-
570
- ### indent
571
- Indents a given code block with `count` spaces before it.
572
-
573
- ### unindent
574
- __Internal:__ Normalizes indentation on a given string.
575
-
576
- Returns the normalized string without extraneous indentation.
577
-
578
- ~~~ ruby
579
- puts unindent %{
580
- Hello
581
- There
582
- }
583
- # Output:
584
- # Hello
585
- # There
586
- ~~~
587
-
588
- ### reindent
589
- Resets the indentation on a given code block.
590
-
591
- ### capture
592
- Returns the output of command via SSH.
593
-
594
- # Helpers: Deploy helpers
595
- Helpers for deployment.
596
-
597
- ### deploy
598
- Wraps the things inside it in a deploy script and queues it.
599
- This generates a script using deploy_script and queues it.
600
-
601
- Returns nothing.
602
-
603
- ### deploy_script
604
- Wraps the things inside it in a deploy script.
605
-
606
- ~~~ ruby
607
- script = deploy_script do
608
- invoke :'git:checkout'
609
- end
610
- queue script
611
- ~~~
612
-
613
- Returns the deploy script as a string, ready for `queue`ing.
614
-
615
- # Modules: Bundler
616
- Adds settings and tasks for managing Ruby Bundler.
617
-
618
- ~~~ ruby
619
- require 'mina/bundler'
620
- ~~~
621
-
622
- ## Settings
623
- Any and all of these settings can be overriden in your `deploy.rb`.
624
-
625
- ### bundle_bin
626
- Sets the bundle path.
627
-
628
- ### bundle_path
629
- Sets the path to where the gems are expected to be.
630
-
631
- This path will be symlinked to `./shared/bundle` so that the gems cache will
632
- be shared between all releases.
633
-
634
- ### bundle_withouts
635
- Sets the colon-separated list of groups to be skipped from installation.
636
-
637
- ### bundle_options
638
- Sets the options for installing gems via Bundler.
639
-
640
- ## Deploy tasks
641
- These tasks are meant to be invoked inside deploy scripts, not invoked on
642
- their own.
643
-
644
- ### bundle:install
645
- Installs gems.
646
-
647
- # Modules: Default
648
- This module is loaded when invoking `mina` with or without a project.
649
-
650
- ## Settings
651
- Here are some of the common settings. All settings are optional unless
652
- otherwise noted.
653
-
654
- ### deploy_to
655
- (Required) Path to deploy to.
656
-
657
- ### domain
658
- (Required) Host name to deploy to.
659
-
660
- ### port
661
- SSH port number.
662
-
663
- ### forward_agent
664
- If set to `true`, enables SSH agent forwarding.
665
-
666
- ### identity_file
667
- The local path to the SSH private key file.
668
-
669
- ### ssh_options
670
- Switches to be passed to the `ssh` command.
671
-
672
- ### env_vars
673
- Environment variables to be passed to `ssh` command. (e.g. "foo=bar baz=1")
674
-
675
- ## Tasks
676
- Any and all of these settings can be overriden in your `deploy.rb`.
677
-
678
- ### environment
679
- Make the `:environment` task exist by default. This is meant to be overridden
680
- by users.
681
-
682
- ### init
683
- Initializes a new Mina project.
684
-
685
- ~~~ ruby
686
- $ mina init
687
- ~~~
688
-
689
- ### help
690
- Shows the help screen.
691
-
692
- ### tasks
693
- Display all tasks in a nice table.
694
-
695
- ~~~ ruby
696
- $ mina tasks
697
- ~~~
698
-
699
- ### ssh
700
- Connects to the server via ssh and cd to deploy_to folder
701
-
702
- ~~~ ruby
703
- $ mina ssh
704
- ~~~
705
-
706
- # Modules: Deployment
707
- This module is automatically loaded for all Mina projects.
708
-
709
- ## Settings
710
- Any and all of these settings can be overriden in your `deploy.rb`.
711
-
712
- ### releases_path
713
- (default: 'releases')
714
-
715
- ### shared_path
716
- (default: 'shared')
717
-
718
- ### current_path
719
- (default: 'current_path')
720
-
721
- ### lock_file
722
- Name of the file to generate while a deploy is currently ongoing.
723
- (default: 'deploy.lock')
724
-
725
- ### keep_releases
726
- Number of releases to keep when doing the `deploy:cleanup` task.
727
- (default: 5)
728
-
729
- ## Tasks
730
-
731
- ### deploy:force_unlock
732
- Forces a deploy unlock by deleting the lock file.
733
-
734
- ~~~ ruby
735
- $ mina deploy:force_unlock
736
- ~~~
737
-
738
- You can also combine that task with `deploy`:
739
-
740
- ~~~ ruby
741
- $ mina deploy:force_unlock deploy
742
- ~~~
743
-
744
- ### deploy:link_shared_paths
745
- Links the shared paths in the `shared_paths` setting.
746
-
747
- ### deploy:cleanup
748
- Cleans up old releases.
749
-
750
- By default, the last 5 releases are kept on each server (though you can
751
- change this with the keep_releases setting). All other deployed revisions
752
- are removed from the servers."
753
-
754
- ### deploy:rollback
755
- Rollbacks the latest release.
756
-
757
- Changes the current link to previous release, and deletes the newest deploy release
758
- Does NOT rollback the database, use
759
-
760
- ~~~ ruby
761
- mina "rake[db:rollback]"
762
- ~~~
763
-
764
- Delete existing sym link and create a new symlink pointing to the previous release
765
-
766
- Remove latest release folder (current release)
767
-
768
- ### setup
769
- Sets up a site's directory structure.
770
-
771
- ### run[]
772
- Runs a command on a server.
773
-
774
- ~~~ ruby
775
- $ mina "run[tail -f logs.txt]"
776
- ~~~
777
-
778
- # Modules: Foreman
779
- Adds settings and tasks for managing projects with [foreman].
780
-
781
- NOTE: Requires sudo privileges
782
-
783
- [foreman]: http://rubygems.org/ddolar/foreman
784
-
785
- require 'mina/foreman'
786
-
787
- ## Common usage
788
-
789
- set :application, "app-name"
790
-
791
- task :deploy => :environment do
792
- ~~~ ruby
793
- deploy do
794
- # ...
795
- invoke 'foreman:export'
796
- # ...
797
- end
798
- to :launch do
799
- invoke 'foreman:restart'
800
- end
801
- ~~~
802
-
803
- end
804
-
805
- ## Settings
806
- Any and all of these settings can be overriden in your `deploy.rb`.
807
-
808
- ### foreman_app
809
- Sets the service name that foreman will export to upstart. Uses *application*
810
- variable as a default. It should be set, otherwise export command will fail.
811
-
812
- ### foreman_user
813
- Sets the user under which foreman will execute the service. Defaults to *user*
814
-
815
- ### foreman_log
816
- Sets the foreman log path. Defaults to *shared/log*
817
-
818
- encoding: utf-8
819
-
820
- # Modules: Git
821
- Adds settings and tasks related to managing Git.
822
-
823
- ~~~ ruby
824
- require 'mina/git'
825
- ~~~
826
-
827
- ## Settings
828
- Any and all of these settings can be overriden in your `deploy.rb`.
829
-
830
- ### branch
831
- Sets the branch to be deployed.
832
-
833
- ## Deploy tasks
834
- These tasks are meant to be invoked inside deploy scripts, not invoked on
835
- their own.
836
-
837
- ### git:clone
838
- Clones the Git repository. Meant to be used inside a deploy script.
839
-
840
- ### git:revision
841
- Gets the current git revision deployed on server.
842
-
843
- # Modules: Rails
844
- Adds settings and tasks for managing Rails projects.
845
-
846
- ~~~ ruby
847
- require 'mina/rails'
848
- ~~~
849
-
850
- ## Settings
851
- Any and all of these settings can be overriden in your `deploy.rb`.
852
-
853
- ### rails_env
854
- Sets the Rails environment for `rake` and `rails` commands.
855
-
856
- Note that changing this will NOT change the environment that your application
857
- is run in.
858
-
859
- ### bundle_prefix
860
- Prefix for Bundler commands. Often to something like `RAILS_ENV=production
861
- bundle exec`.
862
-
863
- ~~~ ruby
864
- queue! "#{bundle_prefix} annotate -r"
865
- ~~~
866
-
867
- ### rake
868
- The prefix for `rake` commands. Use like so:
869
-
870
- ~~~ ruby
871
- queue! "#{rake} db:migrate"
872
- ~~~
873
-
874
- ### rails
875
- The prefix for `rails` commands. Use like so:
876
-
877
- ~~~ ruby
878
- queue! "#{rails} console"
879
- ~~~
880
-
881
- ### asset_paths
882
- The paths to be checked.
883
-
884
- Whenever assets are compiled, the asset files are checked if they have
885
- changed from the previous release.
886
-
887
- If they're unchanged, compiled assets will simply be copied over to the new
888
- release.
889
-
890
- Override this if you have custom asset paths declared in your Rails's
891
- `config.assets.paths` setting.
892
-
893
- ### compiled_asset_path
894
- The path to be copied to the new release.
895
-
896
- The path your assets are compiled to. If your `assets_path` assets have changed,
897
- this is the folder that gets copied accross from the current release to the new release.
898
-
899
- Override this if you have custom public asset paths.
900
-
901
- ### rake_assets_precompile
902
- The command to invoke when precompiling assets.
903
- Override me if you like.
904
-
905
- ----
906
-
907
- Macro used later by :rails, :rake, etc
908
-
909
- ## Command-line tasks
910
- These tasks can be invoked in the command line.
911
-
912
- ### rails[]
913
- Invokes a rails command.
914
-
915
- ~~~ ruby
916
- $ mina "rails[console]"
917
- ~~~
918
-
919
- ### rake[]
920
- Invokes a rake command.
921
-
922
- ~~~ ruby
923
- $ mina "rake[db:migrate]"
924
- ~~~
925
-
926
- ### console
927
- Opens the Ruby console for the currently-deployed version.
928
-
929
- ~~~ ruby
930
- $ mina console
931
- ~~~
932
-
933
- ### log
934
- Tail log from server
935
-
936
- ~~~ ruby
937
- $ mina log
938
- ~~~
939
-
940
- ## Deploy tasks
941
- These tasks are meant to be invoked inside deploy scripts, not invoked on
942
- their own.
943
-
944
- ### rails:db_migrate
945
-
946
- ### rails:db_migrate:force
947
-
948
- ### rails:db_create
949
-
950
- ### rails:db_rollback
951
-
952
- ### rails:assets_precompile:force
953
-
954
- ### rails:assets_precompile
955
-
956
- # Modules: rbenv
957
- Adds settings and tasks for managing [rbenv] installations.
958
-
959
- [rbenv]: https://github.com/sstephenson/rbenv
960
-
961
- ~~~ ruby
962
- require 'mina/rbenv'
963
- ~~~
964
-
965
- ## Common usage
966
-
967
- ~~~ ruby
968
- task :environment do
969
- invoke :'rbenv:load'
970
- end
971
- task :deploy => :environment do
972
- ...
973
- end
974
- ~~~
975
-
976
- ## Settings
977
- Any and all of these settings can be overriden in your `deploy.rb`.
978
-
979
- ### rbenv_path
980
- Sets the path where *rbenv* is installed.
981
-
982
- You may override this if rbenv is placed elsewhere in your setup.
983
-
984
- ## Tasks
985
-
986
- ### rbenv:load
987
- Loads the *rbenv* runtime.
988
-
989
- # Modules: RVM
990
- Adds settings and tasks for managing [RVM] installations.
991
-
992
- [rvm]: http://rvm.io
993
-
994
- ~~~ ruby
995
- require 'mina/rvm'
996
- ~~~
997
-
998
- ## Common usage
999
-
1000
- ~~~ ruby
1001
- task :environment do
1002
- invoke :'rvm:use[ruby-1.9.3-p125@gemset_name]'
1003
- end
1004
- task :deploy => :environment do
1005
- ...
1006
- end
1007
- ~~~
1008
-
1009
- ## Settings
1010
- Any and all of these settings can be overriden in your `deploy.rb`.
1011
-
1012
- ### rvm_path
1013
- Sets the path to RVM.
1014
-
1015
- You can override this in your projects if RVM is installed in a different
1016
- path, say, if you have a system-wide RVM install.
1017
-
1018
- ## Tasks
1019
-
1020
- ### rvm:use[]
1021
- Uses a given RVM environment provided as an argument.
1022
-
1023
- This is usually placed in the `:environment` task.
1024
-
1025
- ~~~ ruby
1026
- task :environment do
1027
- invoke :'rvm:use[ruby-1.9.3-p125@gemset_name]'
1028
- end
1029
- ~~~
1030
-
1031
- ### rvm:wrapper[]
1032
- Creates a rvm wrapper for a given executable.
1033
-
1034
- This is usually placed in the `:setup` task.
1035
-
1036
- ~~~ ruby
1037
- task ::setup => :environment do
1038
- ...
1039
- invoke :'rvm:wrapper[ruby-1.9.3-p125@gemset_name,wrapper_name,binary_name]'
1040
- end
1041
- ~~~
1042
-
1043
- Adds settings and tasks for managing Node packages.
1044
-
1045
- ~~~ ruby
1046
- require 'mina/npm'
1047
- ~~~
1048
-
1049
- ## Settings
1050
- Any and all of these settings can be overriden in your `deploy.rb`.
1051
-
1052
- ### npm_bin
1053
- Sets the npm binary.
1054
-
1055
- ### bower_bin
1056
- Sets the bower binary.
1057
-
1058
- ### grunt_bin
1059
- Sets the grunt binary.
1060
-
1061
- ### npm_options
1062
- Sets the options for installing modules via npm.
1063
-
1064
- ### bower_options
1065
- Sets the options for installing modules via bower.
1066
-
1067
- ### grunt_options
1068
- Sets the options for grunt.
1069
-
1070
- ### grunt_task
1071
- Sets the task parameters for grunt.
1072
-
1073
- ## Deploy tasks
1074
- These tasks are meant to be invoked inside deploy scripts, not invoked on
1075
- their own.
1076
-
1077
- ### npm:install
1078
- Installs node modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
27
+ Documentation
28
+ ----------------
1079
29
 
1080
- ### bower:install
1081
- Installs bower modules. Takes into account if executed `in_directory` and namespaces the installed modules in the shared folder.
30
+ For quick start check out [Getting starting guide](docs/getting_started.md)
1082
31
 
1083
- ### grunt:install
1084
- Launch a task with grunt. Set the grunt_task (defaults to \"build\") variable before calling this.
32
+ For migrating your current 0.3.x deploy scripts, please look at the [migrating guide](docs/migrating.md)
1085
33
 
1086
- # Modules: Whenever
1087
- Adds settings and tasks for managing projects with [whenever].
34
+ For FAQ please visit the [faq](docs/faq.md)
1088
35
 
1089
- [whenever]: http://rubygems.org/gems/whenever
36
+ For other documentation please visit the [docs](docs)
1090
37
 
1091
- ## Common usage
1092
- ~~~ ruby
1093
- require 'mina/whenever'
1094
- task :deploy => :environment do
1095
- deploy do
1096
- ...
1097
- to :launch do
1098
- invoke :'whenever:update'
1099
- end
1100
- end
1101
- ~~~
38
+ Acknowledgements
39
+ ----------------
1102
40
 
1103
- 3rd party modules
1104
- ------
41
+ © 2012-2015, Nadarei.
42
+ 2015-2016, Infinum.
43
+ Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
1105
44
 
1106
- * [mina-rollbar](https://github.com/code-lever/mina-rollbar)
1107
- * [mina-stack](https://github.com/div/mina-stack)
1108
- * [mina-rsync](https://github.com/moll/mina-rsync)
1109
- * [mina-sidekiq](https://github.com/Mic92/mina-sidekiq)
1110
- * [mina-delayed_job](https://github.com/d4be4st/mina-delayed_job)
1111
- * [mina-nginx](https://github.com/hbin/mina-nginx)
1112
- * [mina-newrelic](https://github.com/navinpeiris/mina-newrelic)
1113
- * [mina-rbenv-addons](https://github.com/stas/mina-rbenv-addons)
1114
- * [mina-multistage](https://github.com/endoze/mina-multistage)
1115
- * [mina-s3](https://github.com/stas/mina-s3)
1116
- * [mina-scp](https://github.com/adie/mina-scp)
1117
- * [mina-hooks](https://github.com/elskwid/mina-hooks)
1118
- * [mina-slack](https://github.com/TAKAyukiatkwsk/mina-slack)
1119
- * [mina-cakephp](https://github.com/mobvox/mina-cakephp)
1120
- * [mina-unicorn](https://github.com/openteam/mina-unicorn)
1121
- * [mina-puma](https://github.com/sandelius/mina-puma)
1122
- * [mina-mercurial](https://github.com/rainlabs/mina-mercurial)
1123
- * [mina-faye](https://github.com/NingenUA/mina-faye)
1124
- * [mina-clockwork](https://github.com/907th/mina-clockwork)
1125
- * [mina-ftp](https://github.com/stas/mina-ftp)
1126
- * [mina-laravel](https://github.com/kikyous/mina-laravel)
45
+ Mina is authored [Rico Sta. Cruz][rsc] and [Michael Galero][mg] with help from its [contributors][c] and their startup, [Nadarei][nd].
46
+ It is maintained by [Stjepan Hadjić][sh] and [Gabrijel Škoro][gs] and sponsored by [Infinum][inf].
1127
47
 
1128
- Acknowledgements
1129
- ----------------
48
+ Stjepan:
1130
49
 
1131
- © 2012-2015, Nadarei. Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
50
+ * [Github](https://github.com/d4be4st) (@d4be4st)
51
+ * [Twitter](https://twitter.com/_Beast_) (@_Beast_)
1132
52
 
1133
- Mina is authored and maintained by [Rico Sta. Cruz][rsc] and [Michael
1134
- Galero][mg] with help from its [contributors][c]. It is sponsored by our
1135
- startup, [Nadarei][nd].
53
+ Gabrijel:
1136
54
 
1137
- * [Nadarei](http://nadarei.co) (nadarei.co)
1138
- * [Github](http://github.com/nadarei) (@nadarei)
55
+ * [Github](https://github.com/gabskoro) (@gabskoro)
56
+ * [Twitter](https://twitter.com/gabskoro) (@gabskoro)
1139
57
 
1140
58
  Rico:
1141
59
 
@@ -1148,10 +66,15 @@ Michael:
1148
66
  * [My website][mg] (michaelgalero.com)
1149
67
  * [Github](http://github.com/mikong) (@mikong)
1150
68
 
69
+ Nadrei:
70
+
71
+ * [Nadarei](http://nadarei.co) (nadarei.co)
72
+ * [Github](http://github.com/nadarei) (@nadarei)
73
+
1151
74
  [rsc]: http://ricostacruz.com
1152
75
  [mg]: http://devblog.michaelgalero.com/
1153
76
  [c]: http://github.com/mina-deploy/mina/graphs/contributors
1154
77
  [nd]: http://nadarei.co
1155
- [issues]: https://github.com/mina-deploy/mina/issues
1156
- [trello]: https://trello.com/board/mina/4fc8b3023d9c9a4d72e573e6
1157
-
78
+ [sh]: https://github.com/d4be4st
79
+ [gs]: https://github.com/gabskoro
80
+ [inf]: https://infinum.co