FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
documentcloud/lib/tasks/remote.rake at diffdocs · documentcloud/documentcloud · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
documentcloud
/
documentcloud
Public archive
Notifications
You must be signed in to change notification settings
Fork
157
Star
425
Code
Issues
194
Pull requests
16
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
documentcloud
/
lib
/
tasks
/
remote.rake
Copy path
More file actions
More file actions
Latest commit
History
History
History
100 lines (84 loc) · 2.7 KB
Breadcrumbs
documentcloud
/
lib
/
tasks
/
remote.rake
Copy path
File metadata and controls
100 lines (84 loc) · 2.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Common configuration for remote servers.
namespace
:remote
do
desc
"Open a Remote Rails Console"
task
:console
do
remote
"app:console"
,
central_servers
end
desc
"Start the app servers"
task
:start
do
remote
"app:start"
,
app_servers
end
desc
"Restart the app servers"
task
:restart
do
remote
"app:restart"
,
app_servers
end
desc
"Start all resources, on all servers"
task
:start_all
do
remote
"db:start"
,
central_servers
remote
"sunspot:solr:start"
,
central_servers
remote
"crowd:server:start"
,
central_servers
remote
"crowd:node:start"
,
worker_servers
remote
"openoffice:start"
,
app_servers
remote
"app:start"
,
app_servers
end
desc
"Check the current branch on the app server."
task
:branch
do
remote
"branch"
,
app_servers
end
end
# SSH into a given remote machine. Need to pass the environment.
rule
(
/^ssh:/
)
do
|
t
|
conf
=
configuration
host
=
t
.
name
.
split
(
':'
)
.
last
exec
"ssh -A -i
#{
conf
[
:key
]
}
#{
conf
[
:user
]
}
@
#{
host
}
.documentcloud.org"
end
rule
(
/^remote:branch:/
)
do
|
t
|
branch
=
t
.
name
.
split
(
':'
)
.
last
remote
"branch:
#{
branch
}
"
,
(
central_servers
+
worker_servers
+
app_servers
)
.
uniq
end
rule
(
/^remote:gem:install/
)
do
|
t
|
task_name
=
t
.
name
.
sub
(
/^remote:/
,
''
)
remote
task_name
,
(
central_servers
+
worker_servers
+
app_servers
)
.
uniq
end
rule
(
/^gem:install/
)
do
|
t
|
# rake gem:install:jammit/0.5.1
full_gem
=
t
.
name
.
split
(
':'
)
.
last
gem_name
,
gem_version
=
*
full_gem
.
split
(
'/'
)
version
=
gem_version
?
"--version
#{
gem_version
}
"
:
""
sh
"sudo gem install --no-ri --no-rdoc
#{
gem_name
}
#{
version
}
"
end
def
app_servers
case
RAILS_ENV
when
'staging'
then
[
'staging.documentcloud.org'
]
when
'production'
then
[
'app01.documentcloud.org'
]
end
end
def
central_servers
case
RAILS_ENV
when
'staging'
then
[
'staging.documentcloud.org'
]
when
'production'
then
[
'db01.documentcloud.org'
]
end
end
def
worker_servers
case
RAILS_ENV
when
'staging'
then
[
'staging.documentcloud.org'
]
when
'production'
then
[
'worker01.documentcloud.org'
,
'worker02.documentcloud.org'
,
'worker03.documentcloud.org'
,
'worker04.documentcloud.org'
]
end
end
def
configuration
case
RAILS_ENV
when
'staging'
then
{
:user
=>
'ubuntu'
,
:dir
=>
'~/documentcloud'
,
:key
=>
'secrets/keys/documentcloud.pem'
}
when
'production'
then
{
:user
=>
'ubuntu'
,
:dir
=>
'~/documentcloud'
,
:key
=>
'secrets/keys/documentcloud.pem'
}
end
end
def
remote
(
commands
,
machines
)
commands
=
[
commands
]
.
flatten
conf
=
configuration
todo
=
[
]
todo
<<
"cd
#{
conf
[
:dir
]
}
"
todo
<<
"rake
#{
RAILS_ENV
}
#{
commands
.
join
(
' '
)
}
"
machines
.
each
do
|
host
|
puts
"
\n
--
#{
host
}
--"
system
"ssh -A -t -i
#{
conf
[
:key
]
}
#{
conf
[
:user
]
}
@
#{
host
}
'
#{
todo
.
join
(
' && '
)
}
'"
end
end
Back
|
FazBrowse Home
|
New Git URL