Sha256: 593655b0c1ca382fcc58bb6ff6566e568c895918c9fa50667faa74966f203462

Contents?: true

Size: 1.71 KB

Versions: 61

Compression:

Stored size: 1.71 KB

Contents

# The main Smartcloud Grids Mysql driver
module Smartcloud
	module Grids
		class Mysql < Smartcloud::Base
			def initialize
			end

			def self.up(exposed)
				if Smartcloud::Docker.running?
					# Creating networks
					unless system("docker network inspect mysql-network", [:out, :err] => File::NULL)
						print "-----> Creating network mysql-network ... "
						if system("docker network create mysql-network", out: File::NULL)
							puts "done"
						end
					end

					# Creating & Starting containers
					print "-----> Creating container mysql ... "
					if system("docker create \
						--name='mysql' \
						--env MYSQL_RANDOM_ROOT_PASSWORD=yes \
						#{"--publish='3306:3306'" if exposed == '--exposed'} \
						--volume='#{Smartcloud.config.user_home_path}/.smartcloud/grids/grid-mysql/data:/var/lib/mysql' \
						--restart='always' \
						--network='mysql-network' \
						mysql:5.7.27 \
						--default-authentication-plugin=mysql_native_password", out: File::NULL)

						puts "done"
						print "-----> Starting container mysql ... "
						if system("docker start mysql", out: File::NULL)
							puts "done"
						end
					end
				end
			end
	
			def self.down
				if Smartcloud::Docker.running?
					# Stopping & Removing containers - in reverse order
					print "-----> Stopping container mysql ... "
					if system("docker stop 'mysql'", out: File::NULL)
						puts "done"
						print "-----> Removing container mysql ... "
						if system("docker rm 'mysql'", out: File::NULL)
							puts "done"
						end
					end

					# Removing networks
					print "-----> Removing network mysql-network ... "
					if system("docker network rm mysql-network", out: File::NULL)
						puts "done"
					end
				end
			end			
		end
	end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
smartcloud-0.1.0 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.rc4 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.rc3 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.rc2 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.rc1 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.beta5 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.beta4 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.beta3 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.beta2 lib/smartcloud/grids/mysql.rb
smartcloud-0.1.0.beta1 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.210 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.209 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.208 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.207 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.206 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.205 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.204 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.203 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.202 lib/smartcloud/grids/mysql.rb
smartcloud-0.0.201 lib/smartcloud/grids/mysql.rb