[4.03.20] Customer probes
This commit is contained in:
parent
c19b935c61
commit
3d94e22638
@ -6,7 +6,7 @@ metadata:
|
||||
name: RESOURCE_NAME
|
||||
namespace: production
|
||||
spec:
|
||||
replicas: 1
|
||||
replicas: 0
|
||||
selector:
|
||||
matchLabels:
|
||||
app: RESOURCE_NAME
|
||||
@ -64,24 +64,24 @@ spec:
|
||||
ports:
|
||||
- containerPort: 9090
|
||||
name: RESOURCE_NAME
|
||||
# livenessProbe:
|
||||
# httpGet:
|
||||
# path: /
|
||||
# port: 9090
|
||||
# initialDelaySeconds: 30
|
||||
# periodSeconds: 30
|
||||
# timeoutSeconds: 1
|
||||
# successThreshold: 1
|
||||
# failureThreshold: 3
|
||||
# readinessProbe:
|
||||
# httpGet:
|
||||
# port: 9090
|
||||
# path: /
|
||||
# initialDelaySeconds: 30
|
||||
# periodSeconds: 5
|
||||
# timeoutSeconds: 1
|
||||
# successThreshold: 1
|
||||
# failureThreshold: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 5000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 1
|
||||
successThreshold: 1
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: 5000
|
||||
path: /readiness
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 1
|
||||
successThreshold: 1
|
||||
failureThreshold: 10
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
requests:
|
||||
|
||||
12
src/main.py
12
src/main.py
@ -6,12 +6,20 @@ sys.path.append('/home/price-collector/')
|
||||
from threading import Thread
|
||||
from pricing.collector import collector
|
||||
|
||||
from probes.probes import runFlaskProbes
|
||||
|
||||
def callCollector(args):
|
||||
collector(args)
|
||||
|
||||
def callProbes():
|
||||
runFlaskProbes()
|
||||
|
||||
if __name__=='__main__':
|
||||
|
||||
Thread(target=callProbes).start()
|
||||
|
||||
# Dynamically create new child for each currency
|
||||
currencies = [ "btc_usd" ]
|
||||
|
||||
for i in range(len(currencies)):
|
||||
Thread(target=callCollector, args=[currencies[i]]).start()
|
||||
# for i in range(len(currencies)):
|
||||
# Thread(target=callCollector, args=[currencies[i]]).start()
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import sys
|
||||
|
||||
from time import sleep
|
||||
|
||||
from pricing.bitfinex import bitfinexPublicTicker, bitfinexHighLowVol
|
||||
|
||||
0
src/probes/__init__.py
Normal file
0
src/probes/__init__.py
Normal file
52
src/probes/probes.py
Normal file
52
src/probes/probes.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from flask import Flask
|
||||
|
||||
import json
|
||||
|
||||
from pricing.coinbase import coinbasePublicTicker
|
||||
|
||||
import logging as logger
|
||||
logger.basicConfig(
|
||||
level=logger.INFO,
|
||||
format="%(asctime)s: %(levelname)s -- %(message)s",
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/health')
|
||||
def health():
|
||||
return json.dumps({'status': 'UP'}), 200, {'ContentType':'application/json'}
|
||||
|
||||
@app.route('/readiness')
|
||||
def readiness():
|
||||
# Can it make a call to an exchange?
|
||||
price = coinbasePublicTicker('btc_usd', logger)
|
||||
|
||||
if price != 0 :
|
||||
return json.dumps({
|
||||
'status': 'UP',
|
||||
'app': {
|
||||
'name': 'CryptoSky Price Collector',
|
||||
'description': 'Projects Price Collector service that collects the: High, Low, Open, Close prices, Volume and calculates average price for the hour.',
|
||||
'check_status': 'Success - Call to coinbase exchange',
|
||||
'price': price
|
||||
}
|
||||
}), 200, {'ContentType': 'application/json'}
|
||||
else:
|
||||
return json.dumps({
|
||||
'status': 'DOWN',
|
||||
'app': {
|
||||
'name': 'CryptoSky Price Collector',
|
||||
'description': 'Projects Price Collector service that collects the: High, Low, Open, Close prices, Volume and calculates average price for the hour.',
|
||||
'check_status': 'Failed - Call to coinbase exchange',
|
||||
'price': price
|
||||
}
|
||||
}), 503, {'ContentType': 'application/json'}
|
||||
|
||||
def runFlaskProbes():
|
||||
app.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
runFlaskProbes()
|
||||
Loading…
x
Reference in New Issue
Block a user