dokuen 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,22 +8,12 @@ your own machine. Currently, Dokuen supports Mac and Ubuntu. [Here](http://bugsp
8
8
  * [Gitolite](https://github.com/sitaramc/gitolite)
9
9
  * [Nginx](http://wiki.nginx.org/Main)
10
10
 
11
+
11
12
  ## Installation
12
13
 
13
14
 
14
15
  ### Step 1
15
16
 
16
- WARNING: At the moment Dokuen needs a custom version of Mason. A patch has been accepted but as
17
- of now (2012-05-19) there hasn't been a release with this patch. So, install mason:
18
-
19
- ```
20
- $ git clone https://github.com/peterkeen/mason
21
- $ cd mason
22
- $ gem build mason.gemspec
23
- $ gem install mason-0.0.11.gem
24
- ```
25
-
26
- Then, install dokuen:
27
17
  ```
28
18
  gem install dokuen
29
19
  ```
@@ -50,7 +40,7 @@ $ cd /usr/local/var/dokuen
50
40
  $ sudo dokuen setup .
51
41
  ```
52
42
 
53
- This will ask you a few questions, set up a few directories, and install a few useful commands. It'll also show you some things you need to do.
43
+ This will ask you a few questions, set up a few directories, and install a few useful commands. It'll also show you some things you need to do. Crucially, you'll need to modify your gitolite config and install it.
54
44
 
55
45
  ## Creating an App
56
46
 
@@ -108,6 +98,33 @@ $ ssh git@<your_host> dokuen scale web=0 --application=<name>
108
98
  $ ssh git@<your_host> dokuen scale web=1 --application=<name>
109
99
  ```
110
100
 
101
+
102
+ ## How it works
103
+
104
+ When you run `ssh git@<your_host> dokuen create --application=foo`, Dokuen creates a few directories in it's install directory, setting things up for app deployments. In particular, it creates this structure:
105
+
106
+ ```
107
+ foo/
108
+ releases/ # timestamped code pushes
109
+ env/ # environment variables. FILENAME => file contents
110
+ logs/ # log files, one per process
111
+ build/ # cache directory for build side-effects like gems
112
+ ```
113
+
114
+ When you run `git push dokuen master`, the following series of events happens:
115
+
116
+ * If the target git repo does not exist, gitolite creates it
117
+ * git runs the `pre-receive` hook, which invokes `/path/to/dokuen/install/bin/dokuen`, which is a wrapper around dokuen with the correct config file set
118
+ * runs `git archive <git repo> <sha1 of new master branch> > <tmpdir>`
119
+ * invokes `mason` on the tmpdir, building the application into a timestamped subdirectory of `releases`
120
+ * creates a symlink `current` that points at the new timestamped directory
121
+ * creates a symlink `previous` that points at the previous value of `current`
122
+ * spins up the configured number of processes as set using `dokuen scale`
123
+ * writes out a new nginx configuration and restarts nginx
124
+ * shuts down the previous processes
125
+
126
+ When Dokuen "spins up" a process, it forks the main process, creates a `Dokuen::Wrapper` instance and calls `run!` on it. The wrapper's job is to immediately daemonize and run the command line in the `Procfile` for the given named process, capture logging info, restarting the process if it dies, and forwarding signals to it as appropriate. It writes it's own pid as well as the port it was given at fork-time into a pidfile at `current/.dokuen/dokuen.<appname>.<process_name>.<index>.pid`.
127
+
111
128
  ## Rails
112
129
 
113
130
  Unfortunately the stock Heroku buildpacks install a vendored node.js compiled for the Heroku platform, which happens to be linux. This doesn't work for Mac, which means you have to use a slightly patched version. This one works with a homebrew-installed node.js: https://github.com/peterkeen/heroku-buildpack-ruby
@@ -7,13 +7,20 @@ upstream <%= name %> {
7
7
 
8
8
  server {
9
9
  listen 80;
10
+ <% if use_ssl %>
10
11
  listen 443 ssl;
12
+ <% end %>
11
13
 
12
14
  server_name <%= name %>.<%= config.base_domain_name %>;
15
+ <% additional_domains.each do |domain| %>
16
+ server_name <%= domain %>;
17
+ <% end %>
13
18
 
19
+ <% if use_ssl %>
14
20
  if ($ssl_protocol = "") {
15
21
  rewrite ^ https://$server_name$request_uri? permanent;
16
22
  }
23
+ <% end %>
17
24
 
18
25
  location / {
19
26
  proxy_pass http://<%= name %>;
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_development_dependency('rake')
27
27
  s.add_dependency('thor')
28
- s.add_dependency('mason', ">= 0.1.0")
28
+ s.add_dependency('mason')
29
29
  s.add_dependency('foreman')
30
30
 
31
31
  s.homepage = 'https://github.com/peterkeen/dokuen'
@@ -204,8 +204,6 @@ class Dokuen::Application
204
204
  def install_nginx_config
205
205
  puts "Installing nginx config"
206
206
  sleep 2
207
- @ssl_on = get_env('USE_SSL') ? 'on' : 'off'
208
- @listen_port = get_env('USE_SSL') ? 443 : 80
209
207
  conf = Dokuen.template('nginx', binding)
210
208
  File.open(File.join(config.dokuen_dir, "nginx", "#{name}.#{config.base_domain_name}.conf"), "w+") do |f|
211
209
  f.write(conf)
@@ -306,4 +304,13 @@ private
306
304
  end
307
305
  _ports
308
306
  end
307
+
308
+ def additional_domains
309
+ (env['ADDITIONAL_DOMAINS'] || '').split(',')
310
+ end
311
+
312
+ def use_ssl
313
+ env['USE_SSL']
314
+ end
315
+
309
316
  end
@@ -1,3 +1,3 @@
1
1
  module Dokuen
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
@@ -107,8 +107,15 @@ class Dokuen::Wrapper
107
107
  if not process.kill(term_signal)
108
108
  raise "Failed to kill process #{process.pid}"
109
109
  end
110
+
110
111
  File.delete(pidfile)
111
112
  File.delete("../../../../ports/#{port}")
113
+ sleep 15
114
+
115
+ if process.alive?
116
+ process.kill("KILL")
117
+ end
118
+
112
119
  exit! 0
113
120
  end
114
121
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokuen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000Z
12
+ date: 2012-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 0.1.0
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0
61
+ version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: foreman
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -127,8 +127,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 1.8.19
130
+ rubygems_version: 1.8.24
131
131
  signing_key:
132
132
  specification_version: 3
133
133
  summary: A Personal Application Platform for Macs
134
134
  test_files: []
135
+ has_rdoc: