Add logic to create db, configure supervisor, for install_luigi()
This commit is contained in:
parent
d68b57baa8
commit
7d536499d6
|
@ -26,13 +26,16 @@ Fabric library for Luigi apps
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from rattail_fabric2 import make_deploy, mkdir
|
from rattail_fabric2 import postgresql, make_deploy, mkdir
|
||||||
|
|
||||||
|
|
||||||
deploy_common = make_deploy(__file__)
|
deploy_common = make_deploy(__file__)
|
||||||
|
|
||||||
|
|
||||||
def install_luigi(c, envroot, luigi='luigi', user='rattail', db_connection=None,
|
def install_luigi(c, envroot, luigi='luigi', user='rattail',
|
||||||
|
db=False, dbuser='rattail', dbpass='TODO_PASSWORD',
|
||||||
|
db_connection=None,
|
||||||
|
supervisor=False, autostart=False,
|
||||||
crontab=False, crontab_mailto=None):
|
crontab=False, crontab_mailto=None):
|
||||||
"""
|
"""
|
||||||
Install and configure Luigi to the given virtualenv.
|
Install and configure Luigi to the given virtualenv.
|
||||||
|
@ -55,6 +58,13 @@ def install_luigi(c, envroot, luigi='luigi', user='rattail', db_connection=None,
|
||||||
c.sudo('touch {}/luigitasks/__init__.py'.format(appdir),
|
c.sudo('touch {}/luigitasks/__init__.py'.format(appdir),
|
||||||
user=user)
|
user=user)
|
||||||
|
|
||||||
|
# database
|
||||||
|
if db:
|
||||||
|
postgresql.create_db(c, 'luigi', owner=dbuser)
|
||||||
|
if not db_connection:
|
||||||
|
db_connection = 'postgresql://{}:{}@localhost/luigi'.format(
|
||||||
|
dbuser, dbpass)
|
||||||
|
|
||||||
# config
|
# config
|
||||||
deploy_common(c, 'luigi/luigi.cfg.mako', '{}/luigi/luigi.cfg'.format(appdir),
|
deploy_common(c, 'luigi/luigi.cfg.mako', '{}/luigi/luigi.cfg'.format(appdir),
|
||||||
use_sudo=True, owner=user, mode='0640',
|
use_sudo=True, owner=user, mode='0640',
|
||||||
|
@ -64,6 +74,20 @@ def install_luigi(c, envroot, luigi='luigi', user='rattail', db_connection=None,
|
||||||
use_sudo=True, owner=user,
|
use_sudo=True, owner=user,
|
||||||
context={'appdir': appdir})
|
context={'appdir': appdir})
|
||||||
|
|
||||||
|
# supervisor
|
||||||
|
if supervisor:
|
||||||
|
c.sudo('supervisorctl stop luigi:', warn=True)
|
||||||
|
deploy_common(c, 'luigi/supervisor.conf.mako',
|
||||||
|
'/etc/supervisor/conf.d/luigi.conf',
|
||||||
|
use_sudo=True,
|
||||||
|
context={'envroot': envroot,
|
||||||
|
'appdir': appdir,
|
||||||
|
'user': user,
|
||||||
|
'autostart': autostart})
|
||||||
|
c.sudo('supervisorctl update')
|
||||||
|
if autostart:
|
||||||
|
c.sudo('supervisorctl start luigi:')
|
||||||
|
|
||||||
# logrotate
|
# logrotate
|
||||||
deploy_common(c, 'luigi/luigi-logrotate.conf.mako', '{}/luigi/logrotate.conf'.format(appdir),
|
deploy_common(c, 'luigi/luigi-logrotate.conf.mako', '{}/luigi/logrotate.conf'.format(appdir),
|
||||||
use_sudo=True, owner='root:', # must be owned by root (TODO: why is that again?)
|
use_sudo=True, owner='root:', # must be owned by root (TODO: why is that again?)
|
||||||
|
|
Loading…
Reference in a new issue