-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.py
37 lines (33 loc) · 1.41 KB
/
worker.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from node_manager import NodeManager
class WorkerNodeManager(NodeManager):
def run(self):
kafka_addresses = [
node['private_address'] for node in self.props['services']['kafka']['nodes']
]
kafka_port = self.props['services']['kafka']['props']['internal_port']
kafka_endpoints = f':{kafka_port},'.join(kafka_addresses) + f':{kafka_port}'
self.run_cmd(
'docker run -d '
# Environment variables
+ f"--env JSONRPC_HOST={self.props['node']['private_address']} " +
f"--env JSONRPC_PORT={self.props['jsonrpc_port']} " + f"--env JSONRPC_SCHEME=http "
# Published ports
+
f"--publish {self.props['node']['private_address']}:{self.props['jsonrpc_port']}:{self.props['jsonrpc_port']} "
# Name
+ f"--name {self.props['container_name']} "
# Volumes
+ f"--volume /var/run/docker.sock:/var/run/docker.sock " +
f"--volume /media/adfs:/media/adfs:rw,shared "
# Privileged
+ f"--privileged "
# Restart policy
+ f"--restart always "
# Docker image
+ f"{self.props['container_image']} " + f"worker.py -k {kafka_endpoints}")
# def destroy(self):
# pass
# Destroy containers
# Suicide, todo invocando método por jsonrpc