forked from tata1mg/notifyone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify_setup.py
More file actions
74 lines (59 loc) · 2.99 KB
/
notify_setup.py
File metadata and controls
74 lines (59 loc) · 2.99 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import subprocess
import os
from gateway_setup import setup_gateway
from core_setup import setup_core
from handler_setup import setup_handler
_docker_check_res = subprocess.run(['docker info'], shell=True, capture_output=True)
if _docker_check_res.returncode != 0:
print("Either Docker is not installed or not running\n"+(str(_docker_check_res.stderr.decode('utf-8'))))
exit(1)
print("\n Setting up Postgres on Docker\n")
_res = subprocess.run(['docker pull postgres:14.5'], shell=True, capture_output=True)
if _res.returncode != 0:
print(str(_res.stderr.decode('utf-8')))
exit(1)
_stat = subprocess.run(['docker rm --force postgres_notify'], shell=True)
_res = subprocess.run(["docker run --detach -p5432:5432 -e POSTGRES_PASSWORD='postgres' -e POSTGRES_USER=postgres --name postgres_notify postgres:14.5"], shell=True, capture_output=True)
if _res.returncode != 0:
print(str(_res.stderr.decode('utf-8')))
exit(1)
print("\n Setting up Redis on Docker\n")
_stat = subprocess.run(['docker rm --force redis_notify'], shell=True)
_res = subprocess.run(["docker run --detach --name redis_notify -p 6379:6379 -d redis"], shell=True, capture_output=True)
if _res.returncode != 0:
print(str(_res.stderr.decode('utf-8')))
exit(1)
print("\n Setting up localstack\n")
# install localstack
_res = subprocess.run(['localstack --version'], shell=True, capture_output=True)
if _res.returncode != 0:
print("Localstack not installed \n"+(str(_docker_check_res.stderr.decode('utf-8'))))
print("\n installing localstack \n")
_localstack_res = subprocess.run(['python3 -m pip install --force-reinstall localstack'], shell=True, capture_output=True)
if _localstack_res.returncode != 0:
print(str(_localstack_res.stderr.decode('utf-8')))
exit(1)
else:
pass
else:
pass
_localstack_start_res = subprocess.run(['localstack start -d'], shell=True, capture_output=True)
if _localstack_start_res.returncode != 0:
print(str(_localstack_start_res.stderr.decode('utf-8')))
exit(1)
else:
pass
subprocess.run('rm -rf notifyone-gateway/', shell=True, capture_output=True)
subprocess.run('rm -rf notifyone-core/', shell=True, capture_output=True)
subprocess.run('rm -rf notifyone-handler/', shell=True, capture_output=True)
setup_gateway()
os.chdir('../')
setup_core()
os.chdir('../')
setup_handler()
print('##### Congratulations! NotifyOne system setup Completed #####')
print('Service Hosts - \n\t notifyone-gateway : http://localhost:9401 \n\t notifyone-core : http://localhost:9402 \n\t notifyone-handler : http://localhost:9403')
print('Create App API documentation - \n\t http://localhost:9402/swagger/#/Apps/post_apps')
print('Create Event API documentation - \n\t http://localhost:9402/swagger/#/Events/post_event_create')
print('Send-Notification API documentation - \n\t http://localhost:9401/swagger/#/event_notification/post_send_notification')
print('Get-Notification-Detail API documentation - \n\t http://localhost:9401/swagger/#/event_notification/get_get_notification')