Class: Rigup::Cli

Inherits:
Thor
  • Object
show all
Includes:
CliMethods, Utils::Install, Utils::Run
Defined in:
lib/rigup/cli.rb

Instance Attribute Summary

Attributes included from CliMethods

#context, #release_path, #site_dir

Instance Method Summary collapse

Methods included from CliMethods

#cache_dir, #call_release_command, #checkout_branch_commit, #cleanup, #config, #init, #link_live, #logger, #prepare_cache, #release, #repo, #shared_path, #update_cache

Methods included from Utils::Install

#apply_permissions, #ensure_link, #internal_permissions, #make_public_cache_dir, #override_folder, #permissions_for_web, #permissions_for_web_writable, #select_suffixed_file

Methods included from Utils::Run

#bash, #cd, #pwd, #run, #run_for_all, #sudo, #sudo?, #sudo_available?, #sudo_s

Instance Method Details

#deploy(aPath = nil) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/rigup/cli.rb', line 167

def deploy(aPath=nil)
	init(aPath)
	update_cache
	release
	call_release_command(:install)     # call install_command if defined eg. defaults to "thor deploy:install" eg. make changes to files
	call_release_command(:block)
	link_live
	call_release_command(:restart)     # call restart_command, defaults to "thor deploy:restart" eg. restart passenger
	call_release_command(:unblock)
	cleanup
end

#new(aGitUrl, aPath = nil) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/rigup/cli.rb', line 145

def new(aGitUrl,aPath=nil)
	app_name = File.basename(aGitUrl,'.git')
	aPath ||= app_name
	init(
		aPath,
		{
		:git_url => aGitUrl,
		:app_name => app_name,
		:user => ENV['USER']
		}
	)
	FileUtils.mkdir_p(site_dir)
	FileUtils.mkdir_p(File.join(site_dir,'releases'))
	FileUtils.mkdir_p(File.join(site_dir,'shared'))

	#+ create rigup.yml if doesn't exist, including option values
	h = context.config.to_hash
	h.delete :site_dir
	h.to_yaml.to_file(File.join(site_dir,'rigup.yml'))
end

#restart(aPath = nil) ⇒ Object



180
181
182
183
184
185
186
# File 'lib/rigup/cli.rb', line 180

def restart(aPath=nil)
	init(aPath)
	return unless cmdline = config["restart_command".to_sym].to_s.strip.to_nil
	cd File.join(site_dir,'current') do
		run cmdline
	end
end