Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load RabbitMQ credentials directly using PikaTransport object #434

Merged
merged 6 commits into from
Jan 10, 2025
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/murfey/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import mrcfile
import numpy as np
import uvicorn
import workflows
from backports.entry_points_selectable import entry_points
from fastapi import Request
from fastapi.templating import Jinja2Templates
Expand All @@ -42,6 +41,7 @@
from sqlalchemy.orm.exc import ObjectDeletedError
from sqlmodel import Session, create_engine, select
from werkzeug.utils import secure_filename
from workflows.transport.pika_transport import PikaTransport

import murfey
import murfey.server.ispyb
Expand Down Expand Up @@ -225,6 +225,7 @@


def run():
# Set up argument parser
parser = argparse.ArgumentParser(description="Start the Murfey server")
parser.add_argument(
"--host",
Expand Down Expand Up @@ -273,28 +274,29 @@
help="Increase logging output verbosity",
default=0,
)
# Parse and separate known and unknown args
args, unknown = parser.parse_known_args()

Check warning on line 278 in src/murfey/server/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/__init__.py#L278

Added line #L278 was not covered by tests

# Load the security configuration
security_config = get_security_config()
# setup logging

# Set up GrayLog handler if provided in the configuration
if security_config.graylog_host:
handler = graypy.GELFUDPHandler(
security_config.graylog_host, security_config.graylog_port, level_names=True
)
root_logger = logging.getLogger()
root_logger.addHandler(handler)

# Install a log filter to all existing handlers.
LogFilter.install()

workflows.transport.load_configuration_file(security_config.rabbitmq_credentials)

args = parser.parse_args()

# Set up Zocalo connection
if args.demo:
# Run in demo mode with no connections set up
os.environ["MURFEY_DEMO"] = "1"
else:
_set_up_transport(args.transport)
# Load RabbitMQ configuration and set up the connection
PikaTransport().load_configuration_file(security_config.rabbitmq_credentials)
_set_up_transport("pika")

Check warning on line 299 in src/murfey/server/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/murfey/server/__init__.py#L298-L299

Added lines #L298 - L299 were not covered by tests
d-j-hatton marked this conversation as resolved.
Show resolved Hide resolved

# Set up logging now that the desired verbosity is known
_set_up_logging(quiet=args.quiet, verbosity=args.verbose)
Expand Down
Loading