Skip to content
Snippets Groups Projects
Commit 6dd7cc06 authored by Ravi Tripathi's avatar Ravi Tripathi
Browse files

Add a new function to send socketio messages to the client, and change the...

Add a new function to send socketio messages to the client, and change the socketio message_queue to match the one from flask app
parent 788ae21b
No related tags found
No related merge requests found
...@@ -6,25 +6,28 @@ import subprocess ...@@ -6,25 +6,28 @@ import subprocess
from gevent import monkey from gevent import monkey
monkey.patch_all(subprocess=True) monkey.patch_all(subprocess=True)
broker_url = 'amqp://reggie:reggie@ohpc:5672/socketio' broker_url = 'amqp://reggie:reggie@ohpc:5672/'
#broker_url = 'amqp://' #broker_url = 'amqp://'
celery = Celery('flask_user_reg', broker=broker_url) celery = Celery('flask_user_reg', broker=broker_url)
#socketio = SocketIO(message_queue='amqp:///socketio') #socketio = SocketIO(message_queue='amqp:///socketio')
socketio = SocketIO(message_queue='amqp://reggie:reggie@ohpc:5672/socketio')
#def send_msg(event, room): def send_msg(event, room):
# socketio.emit(event, room=room) print("Post '{}' to room '{}'".format(event,room))
socketio.emit(event, room=room)
@celery.task @celery.task
def celery_create_account(username, fullname, reason, room, socketio): def celery_create_account(username, fullname, reason, session):
room = session
# Todo: Ravi's and Louis's code goes here # Todo: Ravi's and Louis's code goes here
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
#send_msg("creating account", room) send_msg('creating account', room)
socketio.emit("creating account", room=room) #socketio.emit("creating account", room=room)
print(username) print(username)
subprocess.call(["/opt/rabbitmq_agents/flask_producer.py", "ohpc_account_create", username]) subprocess.call(["/opt/rabbitmq_agents/flask_producer.py", "ohpc_account_create", username])
#time.sleep(5) #time.sleep(5)
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username) print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
#send_msg("account ready", room) send_msg('account ready', room)
socketio.emit('account ready', room=room) #socketio.emit('account ready', room=room)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment