Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
a77e9730
Commit
a77e9730
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
new fab file
parent
872147d0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fabfile.py
+51
-13
51 additions, 13 deletions
fabfile.py
with
51 additions
and
13 deletions
fabfile.py
+
51
−
13
View file @
a77e9730
...
...
@@ -3,8 +3,8 @@ Deployment Fabric file
A fabric deployment script for Helios that assumes the following:
- locally, development is /web/helios-server
- remotely,
production is /web/production/helios-server
- remotely,
staging is /web/staging/helios-server
- remotely,
a number of production setups
- remotely,
a number of staging setups
- all of these directories are git checkouts that have a proper origin pointer
Other assumptions that should probably change:
...
...
@@ -15,14 +15,34 @@ Deployment is git and tag based, so:
fab staging_deploy:tag=v3.0.4,hosts=
"
vote.heliosvoting.org
"
fab production_deploy:tag=v3.0.5,hosts=
"
vote.heliosvoting.org
"
also to get the latest
fab production_deploy:tag=latest,hosts=
"
vote.heliosvoting.org
"
IMPORTANT: settings file may need to be tweaked manually
"""
from
fabric.api
import
local
,
settings
,
abort
,
cd
,
run
,
sudo
from
fabric.contrib.console
import
confirm
STAGING_DIR
=
"
/web/staging/helios-server
"
PRODUCTION_DIR
=
"
/web/production/helios-server
"
STAGING_SETUP
=
{
'
root
'
:
"
/web/staging/helios-server
"
,
'
celery
'
:
"
/etc/init.d/staging-celeryd
"
,
'
dbname
'
:
"
helios-staging
"
}
PRODUCTION_SETUPS
=
[
{
'
root
'
:
"
/web/production/helios-server
"
,
'
celery
'
:
"
/etc/init.d/celeryd
"
,
'
dbname
'
:
"
helios
"
},
{
'
root
'
:
"
/web/princeton/helios-server
"
,
'
celery
'
:
"
/etc/init.d/princeton-celeryd
"
,
'
dbname
'
:
"
princeton-helios
"
},
]
def
run_tests
():
result
=
local
(
"
python manage.py test
"
,
capture
=
False
)
...
...
@@ -41,6 +61,20 @@ def check_tag(tag, path):
if
tag
not
in
result
.
split
(
"
\n
"
):
abort
(
"
no remote tag %s
"
%
tag
)
def
get_latest
(
path
):
with
cd
(
path
):
result
=
run
(
'
git pull
'
)
if
result
.
failed
:
abort
(
"
on remote: could not get latest
"
)
result
=
run
(
'
git submodule init
'
)
if
result
.
failed
:
abort
(
"
on remote: could not init submodules
"
)
result
=
run
(
'
git submodule update
'
)
if
result
.
failed
:
abort
(
"
on remote: could not update submodules
"
)
def
checkout_tag
(
tag
,
path
):
with
cd
(
path
):
result
=
run
(
'
git checkout %s
'
%
tag
)
...
...
@@ -66,22 +100,26 @@ def restart_apache():
if
result
.
failed
:
abort
(
"
could not restart apache
"
)
def
restart_celeryd
():
result
=
sudo
(
'
/etc/init.d/celeryd restart
'
)
def
restart_celeryd
(
path
):
result
=
sudo
(
'
%s restart
'
%
celery_path
)
if
result
.
failed
:
abort
(
"
could not restart celeryd
"
)
abort
(
"
could not restart celeryd
- %s
"
%
celery_path
)
def
deploy
(
tag
,
path
):
confirm
(
"
Ready to deploy %s to %s?
"
%
(
tag
,
path
))
run_tests
()
if
tag
==
'
latest
'
:
get_latest
(
path
=
path
)
else
:
check_tag
(
tag
,
path
=
path
)
checkout_tag
(
tag
,
path
=
path
)
migrate_db
(
path
=
path
)
restart_apache
()
def
staging_deploy
(
tag
):
deploy
(
tag
,
path
=
STAGING_
DIR
)
deploy
(
tag
,
path
=
STAGING_
SETUP
[
'
root
'
]
)
def
production_deploy
(
tag
):
deploy
(
tag
,
path
=
PRODUCTION_DIR
)
restart_celeryd
()
for
prod_setup
in
PRODUCTION_SETUPS
:
deploy
(
tag
,
path
=
prod_setup
[
'
root
'
])
restart_celeryd
(
path
=
prod_setup
[
'
celery
'
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment