Run Dummy Http
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py -pf /tmp/dummy_http.pid
- Wait Until Created /tmp/dummy_http.pid timeout=2 second
+ ... stderr=/tmp/dummy_http.log stdout=/tmp/dummy_http.log
+ ${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_http.pid timeout=2 second
+ IF '${status}' == 'FAIL'
+ ${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_http.log
+ IF '${logstatus}' == 'PASS'
+ Log dummy_http.py failed to start. Log output:\n${log} level=ERROR
+ ELSE
+ Log dummy_http.py failed to start. No log file found at /tmp/dummy_http.log level=ERROR
+ END
+ Fail dummy_http.py did not create PID file in 2 seconds
+ END
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTP_PROC=${result}
Run Dummy Https
${result} = Start Process ${RSPAMD_TESTDIR}/util/dummy_http.py
... -c ${RSPAMD_TESTDIR}/util/server.pem -k ${RSPAMD_TESTDIR}/util/server.pem
... -pf /tmp/dummy_https.pid -p 18081
- Wait Until Created /tmp/dummy_https.pid timeout=2 second
+ ... stderr=/tmp/dummy_https.log stdout=/tmp/dummy_https.log
+ ${status} ${error} = Run Keyword And Ignore Error Wait Until Created /tmp/dummy_https.pid timeout=2 second
+ IF '${status}' == 'FAIL'
+ ${logstatus} ${log} = Run Keyword And Ignore Error Get File /tmp/dummy_https.log
+ IF '${logstatus}' == 'PASS'
+ Log dummy_https.py failed to start. Log output:\n${log} level=ERROR
+ ELSE
+ Log dummy_https.py failed to start. No log file found at /tmp/dummy_https.log level=ERROR
+ END
+ Fail dummy_https.py did not create PID file in 2 seconds
+ END
Export Scoped Variables ${RSPAMD_SCOPE} DUMMY_HTTPS_PROC=${result}
Run Dummy Llm
import ssl
import argparse
import os
+import sys
+import traceback
class MainHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
parser.add_argument("--pidfile", "-pf", help="path to the PID file")
args = parser.parse_args()
+ print(f"dummy_http.py: Starting server on {args.bind}:{args.port}", file=sys.stderr)
+
# Create the Tornado application
app = make_app()
# If keyfile and certfile are provided, create an HTTPS server.
# Otherwise, create an HTTP server.
if args.keyfile and args.certfile:
+ print(f"dummy_http.py: Using SSL with cert={args.certfile}, key={args.keyfile}", file=sys.stderr)
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_ctx.load_cert_chain(args.certfile, args.keyfile)
server = tornado.httpserver.HTTPServer(app, ssl_options=ssl_ctx)
else:
server = tornado.httpserver.HTTPServer(app)
+ # Start the server
+ server.bind(args.port, args.bind)
+ server.start(1)
+
# Write the PID to the specified PID file, if provided
+ # Do this AFTER successful bind/start so we know the server is actually running
if args.pidfile:
dummy_killer.write_pid(args.pidfile)
+ print(f"dummy_http.py: PID file written to {args.pidfile}", file=sys.stderr)
- # Start the server
- server.bind(args.port, args.bind)
- server.start(1)
+ print(f"dummy_http.py: Server started successfully, listening on {args.bind}:{args.port}", file=sys.stderr)
await asyncio.Event().wait()
if __name__ == "__main__":
- asyncio.run(main())
+ try:
+ asyncio.run(main())
+ except Exception as e:
+ print(f"dummy_http.py: FATAL ERROR: {type(e).__name__}: {e}", file=sys.stderr)
+ traceback.print_exc(file=sys.stderr)
+ sys.exit(1)