Commit bf375ed9 authored by Ravi Tripathi's avatar Ravi Tripathi Committed by Krish Moodbidri
Browse files

Created a celery task to start account creation and call producer script....

Created a celery task to start account creation and call producer script. Added new function to send socketio messages and message queue to match that of flask

- Adding a process to start account creation process by calling flask_producer script
- Added commented out sections to tasks for future use
- 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 4a8a9ea5
from celery import Celery
import time
from flask_socketio import SocketIO
import subprocess
from gevent import monkey
celery = Celery('flask_user_reg', broker='amqp://')
broker_url = 'amqp://reggie:reggie@ohpc:5672/'
#broker_url = 'amqp://'
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):
print("Post '{}' to room '{}'".format(event,room))
socketio.emit(event, room=room)
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
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
socketio.emit("creating account", room=room)
send_msg('creating account', room)
#socketio.emit("creating account", room=room)
print(username)["/opt/rabbitmq_agents/", "ohpc_account_create", username])
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
socketio.emit('account ready', room=room)
send_msg('account ready', room)
#socketio.emit('account ready', room=room)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment