smartcloud 0.2.4 → 0.3.0

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
  SHA256:
3
- metadata.gz: c09eed268d26951f61505ca47ea77b5c72818ddd6e0ba49eba6ec495c538496a
4
- data.tar.gz: 34e6693c10628e8b4edd2b4615eda938c55642c478c9d9149df82befc2b14114
3
+ metadata.gz: 85369e5e6c9d09e3120c224b6032b3498bd4d7f9fa896245b2f65f601f9c6c88
4
+ data.tar.gz: cde8d32810801ed981f0359dcc82b2fb837cdd10c79c9524c9db248f9fe6379e
5
5
  SHA512:
6
- metadata.gz: 2efa7d3564fb9464ad092d863e097335fa65d07d3e105ecc91b7bb94b801e17f8e981de8628e83a00d6528c3e5621b33874ea3f992f37323136625c513ff6b40
7
- data.tar.gz: 8252096bb15ca63dcea01da601b9b22e2b9c0ea1d92cd69e682639b73724005c4a032d7ca81343a79918c6fd27be5e0dfb379f4965bd8820de5d1b30f6fa81c9
6
+ metadata.gz: f972998785f3eb1931992ae1512e1510f363151fee1c3a328fc422a15a5351bdd1d120f149ee43636dadafcdbdde33f8f906fb1c88db045b6b1c4530bb1c4ed6
7
+ data.tar.gz: d87aa2dec7bb4620bf5ecc9329afe1b53335da305b21e4b0035b81d65fec755243583bde24184cdfeaca560ad7b95ad943aa1fa22f3e1dfbeb2d4296e1f29208
@@ -63,8 +63,8 @@ module Smartcloud
63
63
  --network='nginx-network' \
64
64
  smartcloud/buildpacks/rails", out: File::NULL)
65
65
 
66
- # system("docker network connect solr-network #{new_container}")
67
66
  system("docker network connect mysql-network #{new_container}")
67
+ system("docker network connect elasticsearch-network #{new_container}")
68
68
 
69
69
  if system("docker start --attach #{new_container}")
70
70
  logger.debug "Starting Web Server ..."
@@ -17,6 +17,7 @@ require 'smartcloud/buildpacker'
17
17
 
18
18
  require 'smartcloud/user'
19
19
 
20
+ require 'smartcloud/grids/elasticsearch'
20
21
  require 'smartcloud/grids/mysql'
21
22
  require 'smartcloud/grids/nginx'
22
23
  require 'smartcloud/grids/prereceiver'
@@ -65,6 +65,9 @@ module Smartcloud
65
65
  password: #{SecureRandom.hex(16)}
66
66
  database_name: #{SecureRandom.hex(4)}_production
67
67
 
68
+ elasticsearch:
69
+ port: 9200
70
+
68
71
  redmine:
69
72
  admin_username: admin
70
73
  admin_password: #{SecureRandom.hex(16)}
@@ -0,0 +1,91 @@
1
+ # The main Smartcloud Grids Elasticsearch driver
2
+ module Smartcloud
3
+ module Grids
4
+ class Elasticsearch < Smartcloud::Base
5
+ def initialize
6
+ end
7
+
8
+ def install
9
+ self.uninstall
10
+
11
+ print "-----> Creating settings for elasticsearch ... "
12
+
13
+ vm_max_map_count_filepath = "~/.smartcloud/grids/grid-elasticsearch/vm_max_map_count"
14
+ ssh = Smartcloud::SSH.new
15
+ ssh.run "sudo sysctl -b vm.max_map_count > #{vm_max_map_count_filepath}"
16
+ ssh.run "sudo sysctl -w vm.max_map_count=262144"
17
+
18
+ puts "done"
19
+ end
20
+
21
+ def uninstall
22
+ print "-----> Removing settings for elasticsearch ... "
23
+
24
+ vm_max_map_count_filepath = "~/.smartcloud/grids/grid-elasticsearch/vm_max_map_count"
25
+ ssh = Smartcloud::SSH.new
26
+ ssh.run "test -f #{vm_max_map_count_filepath} && sudo sysctl -w vm.max_map_count=$(cat #{vm_max_map_count_filepath})"
27
+ ssh.run "test -f #{vm_max_map_count_filepath} && rm #{vm_max_map_count_filepath}"
28
+
29
+ puts "done"
30
+ end
31
+
32
+ def self.up(*args)
33
+ args.flatten!
34
+ exposed = args.empty? ? '' : args.shift
35
+
36
+ if Smartcloud::Docker.running?
37
+ # Creating networks
38
+ unless system("docker network inspect elasticsearch-network", [:out, :err] => File::NULL)
39
+ print "-----> Creating network elasticsearch-network ... "
40
+ if system("docker network create elasticsearch-network", out: File::NULL)
41
+ puts "done"
42
+ end
43
+ end
44
+
45
+ # Creating & Starting containers
46
+ print "-----> Creating container elasticsearch ... "
47
+ if system("docker create \
48
+ --name='elasticsearch' \
49
+ --env discovery.type=single-node \
50
+ --env cluster.name=elasticsearch-cluster \
51
+ --env bootstrap.memory_lock=true \
52
+ --env 'ES_JAVA_OPTS=-Xms512m -Xmx512m -Des.enforce.bootstrap.checks=true' \
53
+ --ulimit memlock=-1:-1 \
54
+ --user `id -u`:`id -g` \
55
+ #{"--publish='#{Smartcloud.credentials.elasticsearch[:port]}:#{Smartcloud.credentials.elasticsearch[:port]}'" if exposed == '--exposed'} \
56
+ --volume='#{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-elasticsearch/data:/usr/share/elasticsearch/data' \
57
+ --restart='always' \
58
+ --network='elasticsearch-network' \
59
+ elasticsearch:7.4.1", out: File::NULL)
60
+
61
+ puts "done"
62
+ print "-----> Starting container elasticsearch ... "
63
+ if system("docker start elasticsearch", out: File::NULL)
64
+ puts "done"
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ def self.down
71
+ if Smartcloud::Docker.running?
72
+ # Stopping & Removing containers - in reverse order
73
+ print "-----> Stopping container elasticsearch ... "
74
+ if system("docker stop 'elasticsearch'", out: File::NULL)
75
+ puts "done"
76
+ print "-----> Removing container elasticsearch ... "
77
+ if system("docker rm 'elasticsearch'", out: File::NULL)
78
+ puts "done"
79
+ end
80
+ end
81
+
82
+ # Removing networks
83
+ print "-----> Removing network elasticsearch-network ... "
84
+ if system("docker network rm elasticsearch-network", out: File::NULL)
85
+ puts "done"
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -28,9 +28,15 @@ module Smartcloud
28
28
  ssh = Smartcloud::SSH.new
29
29
  ssh.run "smartcloud buildpacker install"
30
30
  ssh.run "smartcloud prereceiver install"
31
+
32
+ elasticsearch = Smartcloud::Grids::Elasticsearch.new
33
+ elasticsearch.install
31
34
  end
32
35
 
33
36
  def stop
37
+ elasticsearch = Smartcloud::Grids::Elasticsearch.new
38
+ elasticsearch.uninstall
39
+
34
40
  ssh = Smartcloud::SSH.new
35
41
  ssh.run "smartcloud prereceiver uninstall"
36
42
  ssh.run "smartcloud buildpacker uninstall"
@@ -175,6 +181,10 @@ module Smartcloud
175
181
 
176
182
  'grids',
177
183
 
184
+ 'grids/grid-elasticsearch',
185
+ 'grids/grid-elasticsearch/vm_max_map_count',
186
+ 'grids/grid-elasticsearch/data/***',
187
+
178
188
  'grids/grid-mysql',
179
189
  'grids/grid-mysql/data/***',
180
190
 
@@ -206,6 +216,10 @@ module Smartcloud
206
216
 
207
217
  'grids',
208
218
 
219
+ 'grids/grid-elasticsearch',
220
+ 'grids/grid-elasticsearch/data',
221
+ 'grids/grid-elasticsearch/data/.keep',
222
+
209
223
  'grids/grid-mysql',
210
224
  'grids/grid-mysql/data',
211
225
  'grids/grid-mysql/data/.keep',
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Smartcloud
4
- VERSION = "0.2.4".freeze
4
+ VERSION = "0.3.0".freeze
5
5
 
6
6
  def self.version
7
7
  @@version ||= VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timeboard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-26 00:00:00.000000000 Z
11
+ date: 2019-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh
@@ -85,6 +85,8 @@ files:
85
85
  - lib/smartcloud/engine.rb
86
86
  - lib/smartcloud/engine/Dockerfile
87
87
  - lib/smartcloud/engine/buildpacks/rails/Dockerfile
88
+ - lib/smartcloud/grids/elasticsearch.rb
89
+ - lib/smartcloud/grids/grid-elasticsearch/.keep
88
90
  - lib/smartcloud/grids/grid-mysql/docker-entrypoint-initdb.d/.keep
89
91
  - lib/smartcloud/grids/grid-nginx/.keep
90
92
  - lib/smartcloud/grids/grid-prereceiver/Dockerfile
@@ -273,6 +275,7 @@ files:
273
275
  - lib/smartcloud/templates/dotsmartcloud/bin/smartcloud.sh
274
276
  - lib/smartcloud/templates/dotsmartcloud/config/environment.rb
275
277
  - lib/smartcloud/templates/dotsmartcloud/config/users.yml
278
+ - lib/smartcloud/templates/dotsmartcloud/grids/grid-elasticsearch/data/.keep
276
279
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-mysql/data/.keep
277
280
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-nginx/certificates/.keep
278
281
  - lib/smartcloud/templates/dotsmartcloud/grids/grid-nginx/fastcgi.conf