Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4db55d

Browse files
committed
Merge pull requestalphagov#138 from alphagov/add-mapit-script
Add Mapit scripts
2 parents216971c +b724a96 commitf4db55d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

‎fabfile.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
importlogstream
2727
importmongo
2828
importmainstream_slugs
29+
importmapit
2930
importmysql
3031
importnagios
3132
importnginx

‎mapit.py‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
fromfabric.apiimporttask,settings,sudo,env,run
2+
fromfabric.tasksimportexecute
3+
4+
importapp
5+
importnginx
6+
importpuppet
7+
8+
@task
9+
defupdate_database():
10+
"""Update a Mapit database using a new database dump"""
11+
12+
iflen(env.hosts)>1:
13+
exit('This command should only be run on one Mapit machine at a time')
14+
15+
execute(nginx.gracefulstop)
16+
execute(app.stop,'mapit')
17+
sudo('service collectd stop')
18+
19+
sudo('rm /data/vhost/mapit/data/mapit.sql.gz')
20+
21+
withsettings(sudo_user='postgres'):
22+
sudo("psql -c 'DROP DATABASE mapit;'")
23+
24+
execute(puppet.agent,'--test')
25+
26+
27+
@task
28+
defcheck_database_upgrade():
29+
"""Replay yesterday's Mapit requests to ensure that a database upgrade works"""
30+
31+
sudo("awk '$9==200 {print\"http://localhost\" $7}' /var/log/nginx/mapit.access.log.1 > mapit-200s")
32+
sudo("awk '$9==404 {print\"http://localhost\" $7}' /var/log/nginx/mapit.access.log.1 > mapit-404s")
33+
34+
print"Replaying Mapit 200s. Ensure that they are all still 200s."
35+
run('while read line; do curl -sI $line | grep HTTP/1.1 ; done < mapit-200s | sort | uniq -c')
36+
print"Replaying Mapit 404s. Ensure that they are all either 200s or 404s."
37+
run('while read line; do curl -sI $line | grep HTTP/1.1 ; done < mapit-404s | sort | uniq -c')
38+
39+
sudo('rm ~/mapit-200s ~/mapit-404s')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp