[06.03.20] Probes and exposing another port
This commit is contained in:
parent
6ad25f3b1c
commit
f1a2520700
@ -7,4 +7,5 @@ RUN apt update -y && \
|
||||
COPY . /home/spam-filter/.
|
||||
RUN python3 /home/spam-filter/configuration/scripts/nltk_package_downloads.py
|
||||
EXPOSE 9090
|
||||
EXPOSE 9091
|
||||
CMD ["python", "/home/spam-filter/src/main.py"]
|
||||
@ -12,5 +12,8 @@ spec:
|
||||
- port: 9090
|
||||
protocol: HTTP
|
||||
targetPort: 9090
|
||||
- port: 9091
|
||||
protocol: HTTP
|
||||
targetPort: 9091
|
||||
sessionAffinity: None
|
||||
type: ClusterIP
|
||||
@ -10,6 +10,8 @@ from tweets.tweetFilter import tweetFilter
|
||||
|
||||
from flask import Flask, request
|
||||
|
||||
from probes.probes import runFlaskProbes
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
filter = tweetFilter()
|
||||
@ -24,14 +26,19 @@ def tweetPredict():
|
||||
def callTweetFilter():
|
||||
filter.tweetFilterTrain()
|
||||
|
||||
app.run(port=9090)
|
||||
app.run(port=9090, host="0.0.0.0")
|
||||
|
||||
# def callNewsFilter():
|
||||
# newsFilter()
|
||||
|
||||
def callProbes():
|
||||
runFlaskProbes()
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Console: ", "==== Spam Filter - Tweets & News ====")
|
||||
sys.stdout.flush()
|
||||
|
||||
Thread(target=callProbes).start()
|
||||
|
||||
Thread(target=callTweetFilter).start()
|
||||
# Thread(target=callNewsFilter).start()
|
||||
0
src/probes/__init__.py
Normal file
0
src/probes/__init__.py
Normal file
50
src/probes/probes.py
Normal file
50
src/probes/probes.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from flask import Flask
|
||||
|
||||
import json
|
||||
|
||||
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 = 23
|
||||
|
||||
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(port=9091, host="0.0.0.0")
|
||||
|
||||
if __name__ == '__main__':
|
||||
runFlaskProbes()
|
||||
@ -244,7 +244,7 @@ class tweetFilter(object):
|
||||
pass
|
||||
|
||||
def tweetFilterTrain(self):
|
||||
self.Filter = multinomialNaiveBayes("/home/spam-filter/src/resources/tweet_spam_ham.csv")
|
||||
self.Filter = multinomialNaiveBayes("src/resources/tweet_spam_ham.csv")
|
||||
|
||||
self.Filter.trainFilter()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user