Sha256: eb5409f3dcd31722113aa99daa5f4e247cf7e9fda7e67e302ea438d24e26e7a2

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 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
				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

3 entries across 3 versions & 1 rubygems

Version Path
smartcloud-0.0.169 lib/smartcloud/grids/buildpacker.rb
smartcloud-0.0.168 lib/smartcloud/grids/buildpacker.rb
smartcloud-0.0.167 lib/smartcloud/grids/buildpacker.rb