dokuen 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -12,13 +12,28 @@ Dokuen is a "personal app platform". It's the same idea as all of these PaaS and
12
12
 
13
13
  ### Step 1
14
14
 
15
+ WARNING: At the moment Dokuen needs a custom version of Mason. A patch has been accepted but as
16
+ of now (2012-05-19) there hasn't been a release with this patch. So, install mason:
17
+
18
+ ```
19
+ $ git clone https://github.com/peterkeen/mason
20
+ $ cd mason
21
+ $ gem build mason.gemspec
22
+ $ gem install mason-0.0.11.gem
23
+ ```
24
+
25
+ Then, install dokuen:
15
26
  ```
16
27
  gem install dokuen
17
28
  ```
18
29
 
19
30
  ### Step 2
20
31
 
21
- Install nginx using homebrew.
32
+ Install nginx using homebrew:
33
+
34
+ ```
35
+ $ brew install nginx
36
+ ```
22
37
 
23
38
  ### Step 3
24
39
 
@@ -63,15 +78,15 @@ $ open http://<your_host>:12345/
63
78
 
64
79
  ## Available "app" Sub-commands
65
80
 
66
- * create <name>
67
- * config <name>
68
- * set <key>=<value> ...
69
- * delete <key> ...
70
- * restart_app <name>
71
- * scale <name> <type>=<num>
72
- * buildpacks
73
- * install_buildpack
74
- * remove_buildpack
81
+ * `create <name>`
82
+ * `config <name>`
83
+ * `set <key>=<value> ...`
84
+ * `delete <key> ...`
85
+ * `restart_app <name>`
86
+ * `scale <name> <type>=<num>`
87
+ * `buildpacks`
88
+ * `install_buildpack <url>`
89
+ * `remove_buildpack <name>`
75
90
 
76
91
  ## DNS Setup
77
92
 
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ require "dokuen/version"
3
+ require 'rake'
4
+
5
+ def sys(cmd)
6
+ system(cmd) or raise "Error running #{cmd}"
7
+ end
8
+
9
+ task :build do
10
+ sys "gem build dokuen.gemspec"
11
+ end
12
+
13
+ task :release => :build do
14
+ sys "git tag -a -m 'tag version #{Dokuen::VERSION}' v#{Dokuen::VERSION}"
15
+ sys "git push origin master --tags"
16
+ sys "git push github master --tags"
17
+ sys "gem push dokuen-#{Dokuen::VERSION}.gem"
18
+ end
data/bin/dokuen CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $stdout.sync = true
4
+
3
5
  require "rubygems"
4
6
 
5
7
  begin
data/dokuen.gemspec CHANGED
@@ -1,7 +1,11 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ require 'dokuen/version'
4
+
1
5
  Gem::Specification.new do |s|
2
6
  s.name = 'dokuen'
3
- s.version = '0.0.1'
4
- s.date = '2012-05-19'
7
+ s.version = Dokuen::VERSION
8
+ s.date = `date +%Y-%m-%d`
5
9
 
6
10
  s.summary = 'A Personal Application Platform for Macs'
7
11
  s.description = 'Like Heroku but Personal'
data/lib/dokuen/cli.rb CHANGED
@@ -46,7 +46,7 @@ HERE
46
46
  '/usr/local/var/dokuen/log',
47
47
  '/usr/local/var/dokuen/nginx',
48
48
  '/usr/local/var/dokuen/build',
49
- '/usr/local/var/dokuen/releases',
49
+ '/usr/local/var/dokuen/release',
50
50
  ]
51
51
  FileUtils.mkdir_p(dirs, :mode => 0775)
52
52
  FileUtils.chown(git_username, 'staff', dirs)
@@ -161,13 +161,15 @@ HERE
161
161
  Dokuen.sys("launchctl load -wF #{destpath}")
162
162
  end
163
163
 
164
- desc "run_command [APP] [COMMAND]", "Run a command in the given app's environment"
165
- def run_command(app="", command="")
164
+ desc "run_command [APP]", "Run a command in the given app's environment"
165
+ method_option :command, :aliases => '-C', :desc => "Command to run"
166
+ def run_command(app="")
166
167
  check_app(app)
167
168
  read_env(app)
168
169
 
170
+ ENV['PATH'] = "/usr/local/bin:#{ENV['PATH']}"
169
171
  Dir.chdir(ENV['DOKUEN_RELEASE_DIR']) do
170
- Dokuen.sys("foreman run #{command}")
172
+ Dokuen.sys("foreman run #{options[:command]}")
171
173
  end
172
174
  end
173
175
 
@@ -0,0 +1,3 @@
1
+ module Dokuen
2
+ VERSION = '0.0.2'
3
+ end
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.1
4
+ version: 0.0.2
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-05-19 00:00:00.000000000Z
12
+ date: 2012-05-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -79,24 +79,19 @@ description: Like Heroku but Personal
79
79
  email: pete@bugsplat.info
80
80
  executables:
81
81
  - dokuen
82
- - install_launchdaemon
83
- - pre-receive
84
- - restart_nginx
85
82
  extensions: []
86
83
  extra_rdoc_files: []
87
84
  files:
88
85
  - Gemfile
89
86
  - Gemfile.lock
90
87
  - README.md
88
+ - Rakefile
91
89
  - bin/dokuen
92
- - bin/install_launchdaemon
93
- - bin/pre-receive
94
- - bin/restart_nginx
95
90
  - dokuen.gemspec
96
91
  - lib/dokuen.rb
97
92
  - lib/dokuen/cli.rb
98
- - lib/dokuen/config.rb
99
93
  - lib/dokuen/deploy.rb
94
+ - lib/dokuen/version.rb
100
95
  homepage: https://github.com/peterkeen/dokuen
101
96
  licenses: []
102
97
  post_install_message:
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
-
3
- NAME=`basename $1`
4
- cp $1 /Library/LaunchDaemons
5
- launchctl unload -wF /Library/LaunchDaemons/$NAME
6
- launchctl load -wF /Library/LaunchDaemons/$NAME
data/bin/pre-receive DELETED
@@ -1,122 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'tmpdir'
4
- require 'fileutils'
5
- require 'time'
6
-
7
- MASON = "/usr/local/Cellar/ruby/1.9.3-p125/lib/ruby/gems/1.9.1/gems/mason-0.0.11/bin/mason"
8
- BASE_BUILD_DIR = '/usr/local/var/dokuen/build'
9
- BASE_RELEASE_DIR = '/usr/local/var/dokuen/release'
10
- BASE_NGINX_CONF = '/usr/local/var/dokuen/nginx'
11
- BASE_ENV_DIR = '/usr/local/var/dokuen/env'
12
-
13
- should_deploy = `git config hooks.deploy`.chomp
14
- subdomain = `git config hooks.deploy.subdomain`.chomp
15
- port = `git config hooks.deploy.port`.chomp
16
- foreman = `git config hooks.deploy.foreman`.chomp
17
- buildpack_url = `git config hooks.deploy.buildpack`.chomp
18
- after_deploy = `git config hooks.deploy.after`.chomp
19
-
20
- exit(0) if should_deploy != "true"
21
-
22
- def sys(cmd)
23
- system(cmd) or exit(1)
24
- end
25
-
26
- File.umask(0022)
27
-
28
- git_dir = Dir.getwd
29
- cache_dir = "#{BASE_BUILD_DIR}/#{subdomain}"
30
- now = Time.now().utc().strftime("%Y%m%dT%H%M%S")
31
- release_dir = "#{BASE_RELEASE_DIR}/#{subdomain}/#{now}"
32
- env_dir = "#{BASE_ENV_DIR}/#{subdomain}"
33
-
34
- FileUtils.mkdir_p(cache_dir, :mode => 0777)
35
- FileUtils.mkdir_p(release_dir, :mode => 0777)
36
- FileUtils.mkdir_p(env_dir, :mode => 0777)
37
-
38
- rev = ""
39
- STDIN.each do |line|
40
- puts line
41
- parts = line.split(/\s/)
42
- next if parts[2] != "refs/heads/master"
43
- rev = parts[1]
44
- end
45
-
46
- ENV['GIT_DIR'] = nil
47
- ENV['PATH'] = "/usr/local/bin:#{ENV['PATH']}"
48
-
49
- clone_dir = Dir.mktmpdir
50
-
51
-
52
- sys("git clone #{git_dir} #{clone_dir}")
53
-
54
- Dir.chdir clone_dir
55
-
56
- sys("git reset --hard #{rev}")
57
-
58
- sys("#{MASON} build #{clone_dir} -b #{buildpack_url} -o #{release_dir} -c #{cache_dir}")
59
- sys("chmod -R a+r #{release_dir}")
60
- sys("find #{release_dir} -type d -exec chmod a+x {} \\;")
61
-
62
- if after_deploy != ""
63
- Dir.chdir release_dir
64
- sys("envdir #{env_dir} foreman run #{after_deploy}")
65
- end
66
-
67
- base_port = port.to_i - 200
68
-
69
- launch_agent_contents = <<HERE
70
- <?xml version="1.0" encoding="UTF-8"?>
71
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
72
- <plist version="1.0">
73
- <dict>
74
- <key>KeepAlive</key>
75
- <true/>
76
- <key>Label</key>
77
- <string>info.bugsplat.#{subdomain}</string>
78
- <key>ProgramArguments</key>
79
- <array>
80
- <string>/usr/local/bin/envdir</string>
81
- <string>#{BASE_ENV_DIR}/#{subdomain}</string>
82
- <string>/usr/local/bin/foreman</string>
83
- <string>start</string>
84
- <string>-c</string>
85
- <string>#{foreman}</string>
86
- <string>-f</string>
87
- <string>#{release_dir}/Procfile</string>
88
- <string>-p</string>
89
- <string>#{base_port}</string>
90
- </array>
91
- <key>RunAtLoad</key>
92
- <true/>
93
- <key>UserName</key>
94
- <string>peter</string>
95
- <key>WorkingDirectory</key>
96
- <string>#{release_dir}</string>
97
- </dict>
98
- </plist>
99
- HERE
100
-
101
- puts "Installing LaunchDaemon"
102
- File.open("#{release_dir}/info.bugsplat.#{subdomain}.plist", "w+") do |file|
103
- file.write launch_agent_contents
104
- end
105
- sys("sudo /usr/local/bin/install_launchdaemon #{release_dir}/info.bugsplat.#{subdomain}.plist")
106
-
107
- puts "Restarting Nginx"
108
- File.open("#{BASE_NGINX_CONF}/info.bugsplat.#{subdomain}.conf", "w+") do |file|
109
- file.write <<HERE
110
- server {
111
- server_name #{subdomain}.bugsplat.info;
112
- listen 443;
113
- ssl on;
114
- location / {
115
- proxy_pass http://localhost:#{port}/;
116
- }
117
- }
118
-
119
- HERE
120
- end
121
-
122
- sys("sudo /usr/local/bin/restart_nginx")
data/bin/restart_nginx DELETED
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- /usr/local/sbin/nginx -s reload
data/lib/dokuen/config.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'symboltable'
2
-
3
- module Dockuen
4
- class Config < SymbolTable
5
-
6
- def instance
7
- @instance ||= self.new do |c|
8
- c.
9
- end
10
- end
11
- end