~mthaddon/charms/trusty/logstash/expose-logstash

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python

import os
import sys

sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))

from charmhelpers.core import (
    hookenv,
    host,
)

hooks = hookenv.Hooks()
log = hookenv.log

SERVICE = 'logstash-indexer'


@hooks.hook('start')
def start():
    host.service_restart('redis-server') or host.service_start('redis-server')
    host.service_restart(SERVICE) or host.service_start(SERVICE)


if __name__ == "__main__":
    # execute a hook based on the name the program is called by
    hooks.execute(sys.argv)