-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.py
executable file
·46 lines (39 loc) · 1.68 KB
/
run.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# Copyright (C) 2013 SignalFuse, Inc.
# Start script for ElasticSearch.
# Requires python-yaml for configuration writing.
import os
import yaml
from maestro.guestutils import *
from maestro.extensions.logging.logstash import run_service
os.chdir(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'..'))
# Prepare the YAML configuration and write it.
with open(os.path.join('config', 'elasticsearch.yml'), 'w+') as conf:
yaml.dump({
'cluster.name': os.environ.get('CLUSTER_NAME',
'{}-elasticsearch'.format(get_environment_name())),
'node.name': get_container_name(),
'path.data': '/var/lib/elasticsearch',
'transport.tcp.port': get_port('peer', 9300),
'http.port': get_port('http', 9200),
'network.publish_host': get_container_host_address(),
'discovery': {
'type': 'com.sonian.elasticsearch.zookeeper.discovery.ZooKeeperDiscoveryModule',
'zen.multicast.enabled': False,
},
'sonian.elasticsearch.zookeeper': {
'settings.enabled': False,
'client.host': ','.join(get_node_list('zookeeper', ports=['client'])),
'discovery.state_publishing.enabled': True,
},
'zookeeper.root': os.environ.get('ZOOKEEPER_BASE',
'/{}/elasticsearch'.format(get_environment_name())),
}, conf, default_flow_style=False)
# Start ElasticSearch
run_service(['bin/elasticsearch', '-f'],
# TODO(mpetazzoni): use logtype with next version of Maestro.
# logtype='elasticsearch',
logbase='/var/log/elasticsearch',
logtarget='logstash')