aboutsummaryrefslogtreecommitdiffstats
path: root/modules/gitmirror
diff options
context:
space:
mode:
authorDan Fandrich <danf@mageia.org>2024-02-12 17:32:52 -0800
committerDan Fandrich <danf@mageia.org>2024-02-12 17:36:08 -0800
commit2139d918c72b6b656a914f51add64b82adcc18d9 (patch)
tree165bd64e012354ba57a77f32f044529d318cb123 /modules/gitmirror
parente6621fa48d4575dd454b4e80a27f07dfc659ab8f (diff)
downloadpuppet-2139d918c72b6b656a914f51add64b82adcc18d9.tar
puppet-2139d918c72b6b656a914f51add64b82adcc18d9.tar.gz
puppet-2139d918c72b6b656a914f51add64b82adcc18d9.tar.bz2
puppet-2139d918c72b6b656a914f51add64b82adcc18d9.tar.xz
puppet-2139d918c72b6b656a914f51add64b82adcc18d9.zip
Flush logs in on-the-pull
It's not perfect (logs for requests that are rejected by the server are still buffered) but at least normal requests can be immediately be seen in the logs now. A better approach would be to use a logging function that flushes automatically. Also, wait for the queue thread to complete before exiting so things are left in a clean state.
Diffstat (limited to 'modules/gitmirror')
-rwxr-xr-xmodules/gitmirror/files/on-the-pull10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/gitmirror/files/on-the-pull b/modules/gitmirror/files/on-the-pull
index 7d3ede29..ec2f979b 100755
--- a/modules/gitmirror/files/on-the-pull
+++ b/modules/gitmirror/files/on-the-pull
@@ -189,6 +189,7 @@ class GitUpdater(Thread):
print(str(e), file=sys.stderr)
GitUpdaterQueue.task_done()
+ sys.stderr.flush()
class TimeoutServer(http.server.HTTPServer):
@@ -236,6 +237,8 @@ class PostHandler(http.server.BaseHTTPRequestHandler):
self.send_response(500)
self.end_headers()
+ sys.stderr.flush()
+
def Demote(pidfile, uid, gid):
def result():
@@ -345,14 +348,17 @@ e.g. curl --header 'Content-Type: x-git/repo' --data 'my/repo/name' http://local
parser.error("You can only specify a user if you're also deamonising (with a pid file).")
print("Server started", file=sys.stderr)
+ sys.stderr.flush()
srvr = TimeoutServer((options.addr, options.port), PostHandler)
- GitUpdater(serverprefix, basefolder, options.repoprefix, options.branch, options.cmd).start()
+ updater = GitUpdater(serverprefix, basefolder, options.repoprefix, options.branch, options.cmd)
+ updater.start()
try:
srvr.serve_forever()
except KeyboardInterrupt:
- GitUpdaterQueue.put(None)
srvr.socket.close()
+ GitUpdaterQueue.put(None)
+ updater.join()
if __name__ == "__main__":