Skip to content

Commit

Permalink
Devops stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermigier committed Apr 5, 2012
1 parent e12d8a9 commit 82a882c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 19 deletions.
11 changes: 11 additions & 0 deletions circus.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555

[watcher:planet-gtll]
cmd = /var/www/gtll/planet-production/env/bin/python
args = ring/__init__.py serve
working_dir = /var/www/gtll/planet-production
warmup_delay = 0
numprocesses = 1

26 changes: 26 additions & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from fabric.api import env, run, cd, local, put
import time

env.hosts = ['[email protected]']

STAGING_DIR = "/var/www/gtll/planet-staging"
PRODUCTION_DIR = "/var/www/gtll/planet-production"

def deploy():
local("make clean")
local("rm -f /tmp/planet-gtll.tgz")
local("tar czf /tmp/planet-gtll.tgz --exclude .git --exclude .tox .")
put("/tmp/planet-gtll.tgz", "/tmp/")

run("mkdir -p %s" % STAGING_DIR)
with cd(STAGING_DIR):
run("tar zxf /tmp/planet-gtll.tgz")
run("tox -e py27")

run("mkdir -p %s" % PRODUCTION_DIR)
with cd(PRODUCTION_DIR):
run("sqlite3 data/ring.db .dump > ../backup-data/ring-%d.sql" % int(time.time()))
run("tar zxf /tmp/planet-gtll.tgz")
run("if [ ! -e env ]; then virtualenv env; fi")
run("env/bin/python setup.py develop -U")
run("circusctl restart planet-gtll")
37 changes: 23 additions & 14 deletions ring/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

# Real constants
MINUTE = 60
HOUR = 60*MINUTE
DAY = 24*HOUR
MONTH = 30*DAY
YEAR = 365*DAY
HOUR = 60 * MINUTE
DAY = 24 * HOUR
MONTH = 30 * DAY
YEAR = 365 * DAY

BLOG = {
'url': 'http://www.gt-logiciel-libre.org/',
Expand All @@ -33,6 +33,16 @@
]
}

try:
import newrelic.agent
import os
here = os.path.dirname(__file__)
newrelic.agent.initialize(os.path.join(here, '..', 'newrelic.ini'))
except:
import traceback
traceback.print_exc()
pass


# Use /media instead of default /static because /static is already used.
app = Flask(__name__, static_path='/media')
Expand Down Expand Up @@ -99,28 +109,27 @@ def age(t):
dt = now - t
if dt < MINUTE:
return "%d seconds ago" % dt
if dt < 2*MINUTE:
if dt < 2 * MINUTE:
return "about 1 minute ago"
if dt < HOUR:
return "%d minutes ago" % (dt/MINUTE)
if dt < 2*HOUR:
return "%d minutes ago" % (dt / MINUTE)
if dt < 2 * HOUR:
return "about 1 hour ago"
if dt < DAY:
return "about %d hours ago" % (dt/HOUR)
if dt < 2*DAY:
return "about %d hours ago" % (dt / HOUR)
if dt < 2 * DAY:
return "yesterday"
if dt < MONTH:
return "about %d days ago" % (dt/DAY)
if dt < 2*MONTH:
return "about %d days ago" % (dt / DAY)
if dt < 2 * MONTH:
return "last month"
if dt < YEAR:
return "about %d months ago" % (dt/MONTH)
return "%d years ago" % (dt/YEAR)
return "about %d months ago" % (dt / MONTH)
return "%d years ago" % (dt / YEAR)


def main():
app.run(debug=True)

if __name__ == '__main__':
main()

9 changes: 6 additions & 3 deletions ring/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ <h3>Qui nous sommes</h3>
pour <strong>favoriser le développement de logiciels libres innovants</strong>
qui profitent des avancées scientifiques de l'Ile-de-France.</p>

<p><strong>21 projets</strong> de R&D, labellisés par le GT, ont déjà été financés
pour un <strong>coût total de plus de 60 M€</strong> et un montant de
<strong>subvention de plus de 25,5 M€</strong>.</p>
<p><strong>29 projets</strong> de R&amp;D, labellisés par le GT, ont déjà été financés
pour un <strong>coût total de plus de 105 M€</strong> et un montant de
<strong>subvention de plus de 39 M€</strong>.</p>

<p><strong><a href="http://www.systematic-paris-region.org/fr/logiciel-libre">En savoir plus</a></strong>
sur le site de Systematic.</p>
</div>
</div>

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def params():
license = 'LGPL'

packages = find_packages(exclude=['ez_setup'])
print packages


#namespace_packages = ['ring']
include_package_data = True
zip_safe = False
Expand Down

0 comments on commit 82a882c

Please sign in to comment.