deployku 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e661ae5dab03eea96e83e1111823dc20fbddbc3
4
- data.tar.gz: 9b8ec41b8aedd20c244e94e5035fe699274541e0
3
+ metadata.gz: 03888fb6851ccbe49f3ed0c71f574a246e8d398f
4
+ data.tar.gz: bde52a2e8d1e47c74ef09ae3c96e180e777d60ac
5
5
  SHA512:
6
- metadata.gz: 4fbe627f31cb9d54dc25f92284261bf262d8816b9db26b0a3e20966548f76e31908ae134376e31066e92439c30c1a39b4eda633724de00bc925db7b267064c45
7
- data.tar.gz: e330a1f96280912c65a02dceb1b87f6293c9901f5740c45c31bc2d3a3b34099ba38f9d157105a9a48d9e27b5c0899f9a942a3d19faff1dfcad62461974745f12
6
+ metadata.gz: 31d9cf58462f5a0bde7bda68dd33b71a63b070b2a4d193b4f82ec887af3047915eccf9102f47e4ac6f0863477f60c18066f5c27d4e0ec172e3c5239f8eac30d2
7
+ data.tar.gz: 3cdc657325c5d2562b5282d387e48b813f4f787964eef5f926851f413922b8b7c56a5d0f4564d2608daa149713b331a5d7e8e01281a6ac813fa675a60c8130f8
data/README.md CHANGED
@@ -129,8 +129,15 @@ RUN /bin/bash -l -c 'cd app && RAILS_ENV=production bundle install --without dev
129
129
 
130
130
  ## Supported applications
131
131
 
132
+ ### Autoconfiguration for frameworks
133
+
132
134
  * Ruby on Rails
133
135
 
136
+ ### Services
137
+
138
+ * PostgreSQL
139
+ * Redis
140
+
134
141
  ## Examples
135
142
 
136
143
  ### Create new project and assign commit rights to jane
@@ -150,7 +157,14 @@ ssh deployku@localhost postgres:create dbserver
150
157
  ssh deployku@localhost postgres:start dbserver
151
158
  ```
152
159
 
153
- ### Create and configure new Rails application
160
+ ### Create and start new Redis server
161
+
162
+ ```bash
163
+ ssh deployku@localhost redis:create redis
164
+ ssh deployku@localhost redis:start redis
165
+ ```
166
+
167
+ ### Create and configure new Rails application with PostgreSQL and Redis
154
168
 
155
169
  Create new repository on deployku server (replace localhost with name of your server)
156
170
  ```bash
@@ -167,6 +181,11 @@ Link created database to our application
167
181
  ssh deployku@localhost postgres:db:link dbserver myappdb myapp
168
182
  ```
169
183
 
184
+ Link Redis to our application
185
+ ```bash
186
+ ssh deployku@localhost redis:link redis myapp
187
+ ```
188
+
170
189
  To say that we want to install postgresql dev tools in our container you can create file `deployku.yml` in your
171
190
  application directory:
172
191
  ```yaml
data/deployku.gemspec CHANGED
@@ -13,7 +13,7 @@ spec = Gem::Specification.new do |s|
13
13
  s.email = "pejuko@gmail.com"
14
14
  s.authors = ["Petr Kovář"]
15
15
  s.name = 'deployku'
16
- s.version = '0.0.2'
16
+ s.version = '0.0.3'
17
17
  s.date = Time.now.strftime("%Y-%m-%d")
18
18
  s.require_path = 'lib'
19
19
  s.files = ["bin/deployku", "README.md", "deployku.gemspec", "Rakefile", "LICENSE"]
@@ -1,7 +1,5 @@
1
1
  require 'fileutils'
2
- require 'yaml'
3
2
  require 'securerandom'
4
- require 'open3'
5
3
 
6
4
  module Deployku
7
5
  class PostgresPlugin < Deployku::Plugin
@@ -117,6 +115,12 @@ module Deployku
117
115
  describe :status, '<NAME>', 'show container status', acl_sys: :admin
118
116
  describe :stop, '<NAME>', 'stops running container', acl_sys: :admin
119
117
  describe :restart, '<NAME>', 'restarts container', acl_sys: :admin
118
+ def restart(app_name)
119
+ # restart can not be done seamlessly because we use named containers
120
+ stop(app_name)
121
+ start(app_name)
122
+ end
123
+
120
124
  describe :logs, '<NAME>', 'show app logs', acl_sys: :admin
121
125
 
122
126
  # methods from configurable
@@ -133,7 +137,7 @@ module Deployku
133
137
  end
134
138
 
135
139
  def container_name(app_name)
136
- "deployku-postgres-#{app_name}"
140
+ "deployku-postgres-#{Deployku.sanitize_app_name(app_name)}"
137
141
  end
138
142
  end
139
143
  end
@@ -0,0 +1,95 @@
1
+ require 'fileutils'
2
+ require 'securerandom'
3
+
4
+ module Deployku
5
+ class RedisPlugin < Deployku::Plugin
6
+ include Deployku::Configurable
7
+ include Deployku::Containerable
8
+
9
+ def initialize
10
+ @config = {
11
+ 'from' => 'redis',
12
+ 'env' => {}
13
+ }
14
+ end
15
+
16
+ describe :create, '<NAME>', 'creates new Redis instance', acl_sys: :admin
17
+ def create(name)
18
+ app_dir = dir(name)
19
+ unless Dir.exists?(app_dir)
20
+ FileUtils.mkdir_p(app_dir)
21
+ end
22
+ app_dir
23
+ end
24
+
25
+ describe :delete, '<NAME>', 'deletes an existing Redis instance', acl_sys: :admin
26
+ def delete(name)
27
+ app_dir = dir(name)
28
+ if Dir.exists?(app_dir)
29
+ FileUtils.rm_rf(app_dir)
30
+ end
31
+ end
32
+
33
+ describe :list, '', 'lists available Redis instances', acl_sys: :admin
34
+ def list
35
+ Dir.glob(File.join(Deployku::Config.home, '.redis', '*')) do |path|
36
+ puts File.basename(path) if File.directory?(path)
37
+ end
38
+ end
39
+
40
+ describe 'link', '<NAME> <APP>', 'connect appliaction with redis server', acl_sys: :admin
41
+ def link(name, app_name)
42
+ config_load(name)
43
+ redis_id = get_container_id(name)
44
+ redis_url = "redis://#{container_name(name)}:6379/"
45
+ Deployku::AppPlugin.run('config:set', [app_name, 'REDIS_URL', redis_url])
46
+ Deployku::AppPlugin.run(:link, [app_name, container_name(name)])
47
+ end
48
+
49
+ # methods from containerable
50
+ describe :start, '<NAME>', 'starts container', acl_sys: :admin
51
+ def start(app_name)
52
+ config_load(app_name)
53
+ unless @config['volumes']
54
+ @config['volumes'] = {
55
+ File.join(dir(app_name), 'redis') => '/data/'
56
+ }
57
+ end
58
+ config_save(app_name)
59
+
60
+ Deployku::Config.merge!(@config)
61
+ app_hash = Deployku::Engine.start(@config['from'], dir(app_name), container_name(app_name))
62
+ exit 1 if $?.nil? || $?.exitstatus != 0
63
+ set_container_id(app_name, container_name(app_name))
64
+ puts "Container #{app_hash} started."
65
+ end
66
+
67
+ describe :status, '<NAME>', 'show container status', acl_sys: :admin
68
+ describe :stop, '<NAME>', 'stops running container', acl_sys: :admin
69
+ describe :restart, '<NAME>', 'restarts container', acl_sys: :admin
70
+ def restart(app_name)
71
+ # restart can not be done seamlessly because we use named containers
72
+ stop(app_name)
73
+ start(app_name)
74
+ end
75
+
76
+ describe :logs, '<NAME>', 'show app logs', acl_sys: :admin
77
+
78
+ # methods from configurable
79
+ describe 'config:show', '<NAME>', 'shows instance configuration', acl_sys: :admin
80
+ describe 'config:set', '<NAME> <ENV_VARIABLE> <VALUE>', 'sets environment variable', acl_sys: :admin
81
+ describe 'config:unset', '<NAME> <ENV_VARIABLE>', 'unsets environment variable', acl_sys: :admin
82
+ describe 'config:set_from', '<NAME> <VALUE>', 'sets base image name for container', acl_sys: :admin
83
+ describe 'config:unset_from', '<NAME>', 'sets base image to default', acl_sys: :admin
84
+ describe 'config:set_engine', '<NAME> <ENGINE>', 'sets container engine (docker, lxc)', acl_sys: :admin
85
+ describe 'config:unset_engine', '<NAME>', 'sets engine to default', acl_sys: :admin
86
+
87
+ def dir(name)
88
+ File.join(Deployku::Config.home, '.redis', Deployku.sanitize_app_name(name))
89
+ end
90
+
91
+ def container_name(app_name)
92
+ "deployku-redis-#{Deployku.sanitize_app_name(app_name)}"
93
+ end
94
+ end
95
+ end
data/lib/deployku.rb CHANGED
@@ -15,5 +15,6 @@ require 'deployku/plugins/lxc'
15
15
  require 'deployku/plugins/app'
16
16
  require 'deployku/plugins/git'
17
17
  require 'deployku/plugins/postgres'
18
+ require 'deployku/plugins/redis'
18
19
  require 'deployku/plugins/rails'
19
20
  require 'deployku/plugins/nginx'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deployku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Kovář
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2015-11-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: pejuko@gmail.com
@@ -37,6 +37,7 @@ files:
37
37
  - lib/deployku/plugins/nginx.rb
38
38
  - lib/deployku/plugins/postgres.rb
39
39
  - lib/deployku/plugins/rails.rb
40
+ - lib/deployku/plugins/redis.rb
40
41
  homepage: http://github.com/deployku/deployku
41
42
  licenses: []
42
43
  metadata: {}