Skip to content

Commit

Permalink
Merge pull request #95 from abkfenris/feature/xticks-rotate
Browse files Browse the repository at this point in the history
Hopefully this provides a long term fix for celery beat in addition to rotating the x-tick mark labels around so they are more visible.
  • Loading branch information
abkfenris committed Oct 9, 2015
2 parents 463bee4 + 641429b commit 61712be
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
4 changes: 3 additions & 1 deletion app/main/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ def _axisfigure(self):
for sample in data:
x.append(sample.datetime)
y.append(sample.value)
ax.plot(x, y, '-')
ax.plot_date(x, y, '-')
self._setaxislimits(ax, min(y), max(y))
if self.sensor.name:
ax.set_title('{0} - {1}'.format(self.sensor.gage.name, self.sensor.name))
else:
ax.set_title('{0} - {1}'.format(self.sensor.gage.name, self.sensor.stype.capitalize()))
for item in ax.get_xticklabels():
item.set_rotation(30)
return ax, fig

def matplot(self):
Expand Down
24 changes: 16 additions & 8 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def create_database():
else:
print('{DB} not found! Creating DB'.format(DB=DB))
# require.postgres.user(DB_USER, password=DB_PASSWORD)
sudo('''psql -c "CREATE USER '{DB_USER}' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN UNENCRYPTED PASSWORD '{DB_PASSWORD}';"'''.format(DB_USER=DB_USER, DB_PASSWORD=DB_PASSWORD),
sudo("""psql -c "CREATE USER '{DB_USER}' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN UNENCRYPTED PASSWORD '{DB_PASSWORD}';""".format(DB_USER=DB_USER, DB_PASSWORD=DB_PASSWORD),
user='postgres')
# require.postgres.database(DB, owner=DB_USER)
sudo('createdb --owner {DB_USER} {DB}'.format(DB_USER=DB_USER, DB=DB),
Expand All @@ -128,25 +128,25 @@ def configure_git():
"""
require.directory(GIT_DIR, use_sudo=True)
with cd(GIT_DIR):
sudo('mkdir gage-web.git')
#sudo('mkdir gage-web.git')
with cd('gage-web.git'):
sudo('git init --bare')
#sudo('git init --bare')
with lcd(LOCAL_CONFIG_DIR):
with cd('hooks'):
put('./post-receive', './', use_sudo=True)
sudo('chmod +x post-receive')
with lcd(LOCAL_APP_DIR):
local(
'git remote add production {user}@{server}:{GIT_DIR}/gage-web.git'
.format(user=env.user, server=env.host_string, GIT_DIR=GIT_DIR))
#with lcd(LOCAL_APP_DIR):
# local(
# 'git remote add production {user}@{server}:{GIT_DIR}/gage-web.git'
# .format(user=env.user, server=env.host_string, GIT_DIR=GIT_DIR))


def deploy():
"""
Push current master to production and restart gunicorn
"""
with lcd(LOCAL_APP_DIR):
local('git push production master')
local('git push production')
sudo('supervisorctl restart gage:*')


Expand Down Expand Up @@ -265,6 +265,14 @@ def setup_celery():
sudo('supervisorctl restart gage:*')


def gage_restart():
"""
Cron script to restart the supervisorctl gage:gage-celery-beat hourly
"""
fabtools.cron.add_task('restart-gage-beat', '@hourly', 'root', WWW_DIR+'/server-config/restart-gage.sh')



def bootstrap():
"""
Setup all the things
Expand Down
6 changes: 5 additions & 1 deletion server-config/post-receive
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#!/bin/sh
GIT_WORK_TREE=/home/www/gage-web git checkout -f
while read oldrev newrev ref
do
echo "$ref recieved, probably deploying master"
GIT_WORK_TREE=/home/www/gage-web git checkout -f $ref
done
3 changes: 3 additions & 0 deletions server-config/restart-gage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

supervisorctl restart gage:gage-celery-beat

0 comments on commit 61712be

Please sign in to comment.