33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import os, sys, json, time
|
|
|
|
from services.loft_service import LoftService
|
|
from helpers import aws_helper
|
|
|
|
from daemonize import Daemonize
|
|
from sqs_listener import SqsListener
|
|
|
|
class ServiceListener(SqsListener):
|
|
def handle_message(self, body, attributes, messages_attributes):
|
|
# gather/manage/process data based on the particular needs
|
|
service = LoftService(body)
|
|
service.process()
|
|
# log the things
|
|
|
|
def main():
|
|
print("Starting Solver Service (v0.3.2)...")
|
|
print("Initializing listener")
|
|
listener = ServiceListener(
|
|
'measure-development-solver-ingest',
|
|
region_name=os.environ['SOLVER_AWS_REGION'],
|
|
aws_access_key=os.environ['SOLVER_AWS_ACCESS_KEY_ID'],
|
|
aws_secret_key=os.environ['SOLVER_AWS_SECRET_ACCESS_KEY'],
|
|
queue_url=os.environ['SOLVER_SQS_INGEST_QUEUE']
|
|
)
|
|
listener.listen()
|
|
|
|
if __name__ == '__main__':
|
|
myname=os.path.basename(sys.argv[0])
|
|
pidfile='/tmp/%s' % myname # any name
|
|
daemon = Daemonize(app=myname,pid=pidfile, action=main, foreground=True)
|
|
daemon.start()
|