Sha256: b3fe344fc0fec58cbd96efdf036db502e0c793f77705e88172004b2eadf09b7a

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'open3'

module Smartcloud
	module Grids
		class Buildpacker < Smartcloud::Base
			def initialize
			end

			def pack
				logger.formatter = proc do |severity, datetime, progname, message|
					"\t\t\t------> #{severity}: #{message}\n"
				end

				pack_rails if File.exist? "bin/rails"
				logger.info "Could not continue ... Launch Failed."

				logger.formatter = nil
			end

			def pack_rails
				# Remove server.pid if it exists
				FileUtils.rm("tmp/pids/server.pid") if File.exist? "tmp/pids/server.pid"

				# Perform bundle install
				logger.info "Performing bundle install ..."
				logger.formatter = proc do |severity, datetime, progname, message|
					"\t\t\t\t#{message}"
				end
				exit_status = nil
				Open3.popen2("bundle", "install", "--deployment", "--clean") do |stdin, stdout_andstderr, wait_thr|
					stdout_andstderr.each do |line|
						logger.info "#{line}"
					end
					exit_status = wait_thr.value
				end

				if exit_status.success?
					logger.error "Could not complete bundle install."
				end

				# if system("bundle install --deployment --clean")
				# 	logger.info "Installing Javascript Dependencies & Pre-compiling Assets ..."
				# 	if system("bundle exec rails assets:precompile", out: File::NULL)
				# 		logger.debug "Starting Server ..."
				# 		if system("god -c Godfile -D")
				# 			logger.info "Launched Application ... Success."
				# 		end
				# 		# exit 0
				# 	end
				# end
			end
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartcloud-0.0.170 lib/smartcloud/grids/buildpacker.rb