-
-
Save drbraden/b965f1800d01ad8eb073769344419eb8 to your computer and use it in GitHub Desktop.
A couple of rake tasks to handle Go projects deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :go do | |
task :upload do | |
on release_roles :all do | |
upload! "#{repo_path}/#{fetch(:application)}", release_path | |
end | |
end | |
task :build do | |
run_locally do | |
within repo_path do | |
with fetch(:go_build_env) do | |
execute :go, :build, :'-v' | |
end | |
end | |
end | |
end | |
task :run do | |
on release_roles :all do | |
with fetch(:go_run_env) do | |
within release_path do | |
if test "[ -f pid/#{fetch(:application)}.pid ]" | |
execute :kill, "`cat pid/#{fetch(:application)}.pid`" | |
end | |
execute :nohup, "./#{fetch(:application)}", "#{fetch(:go_run_args, '')} 2>&1 > #{shared_path}/log/#{fetch(:application)}.log & (echo $! > #{shared_path}/pid/#{fetch(:application)}.pid)" | |
end | |
end | |
end | |
end | |
end | |
after 'deploy:updating', 'go:build' | |
after 'go:build', 'go:upload' | |
after 'deploy:finished', 'go:run' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment