Skip to content

Commit dc94812

Browse files
committed
Merge branch 'master' of github.com:pathbox/ruby_little_code
2 parents fbbaec5 + 4352e51 commit dc94812

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

begin_rescue_best_place.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
def test(arg=nil)
2+
begin # outter begin
3+
if arg == 1
4+
10.times.each do |i|
5+
begin # inner begin
6+
if i == 2
7+
raise "here is 2"
8+
else
9+
puts i
10+
end
11+
rescue => e
12+
puts e
13+
end
14+
end
15+
elsif arg == 2
16+
10.times.each do |i|
17+
if i == 2
18+
raise "here is 2"
19+
else
20+
puts i
21+
end
22+
end
23+
else
24+
10.times.each do |i|
25+
if i == 2
26+
raise "here is 2"
27+
else
28+
puts i
29+
end
30+
end
31+
end
32+
rescue => e
33+
puts e
34+
end
35+
end
36+
37+
# inner begin 捕捉异常,且不会中断循环
38+
# outter begin 捕捉异常,但是会中断循环

capistrano_go_deploy.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
set :application, "APPNAME"
2+
set :repository, "[email protected]:YOU/APPNAME.git"
3+
ssh_options[:forward_agent] = true
4+
set :user, 'USERNAME'
5+
set :deploy_to, "/home/#{user}/app"
6+
set :gopath, deploy_to
7+
set :pid_file, deploy_to+'/pids/PIDFILE'
8+
set :symlinks, { "pids" => "pids" }
9+
10+
task :staging do
11+
server "1.stage.example.com", :app
12+
end
13+
14+
task :production do
15+
server '1.app.example.com', :app
16+
server '2.app.example.com', :app
17+
end
18+
19+
after 'deploy:update_code', 'go:build'
20+
21+
namespace :go do
22+
task :build do
23+
with_env('GOPATH', gopath) do
24+
run "go get -u github.com/YOU/APPNAME"
25+
run "mkdir #{release_path}/bin"
26+
run "cp /home/#{user}/go/bin/APPNAME #{release_path}/bin/"
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)