@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "--rate" flag to `bin/harbormaster write-log` to support testing live log streaming

Summary: Depends on D19151. Ref T13088. While dramatically less exciting than using `lolcat` and less general than `pv`, this should do the job adequately.

Test Plan: Piped a sizable log into `bin/harbormaster write-log` with `--rate 2048`, saw a progress bar. Loaded the log in the web UI and saw it grow as the page reloaded.

Reviewers: yelirekim

Reviewed By: yelirekim

Subscribers: yelirekim, PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

Differential Revision: https://secure.phabricator.com/D19152

+39 -2
+38 -1
src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
··· 18 18 'param' => 'id', 19 19 'help' => pht('Build Target ID to attach the log to.'), 20 20 ), 21 + array( 22 + 'name' => 'rate', 23 + 'param' => 'bytes', 24 + 'help' => pht( 25 + 'Limit the rate at which the log is written, to test '. 26 + 'live log streaming.'), 27 + ), 21 28 )); 22 29 } 23 30 ··· 54 61 pht('Reading log content from stdin...')); 55 62 56 63 $content = file_get_contents('php://stdin'); 57 - $log->append($content); 64 + 65 + $rate = $args->getArg('rate'); 66 + if ($rate) { 67 + if ($rate <= 0) { 68 + throw new Exception( 69 + pht( 70 + 'Write rate must be more than 0 bytes/sec.')); 71 + } 72 + 73 + echo tsprintf( 74 + "%s\n", 75 + pht('Writing log, slowly...')); 76 + 77 + $offset = 0; 78 + $total = strlen($content); 79 + $pieces = str_split($content, $rate); 80 + 81 + $bar = id(new PhutilConsoleProgressBar()) 82 + ->setTotal($total); 83 + 84 + foreach ($pieces as $piece) { 85 + $log->append($piece); 86 + $bar->update(strlen($piece)); 87 + sleep(1); 88 + } 89 + 90 + $bar->done(); 91 + 92 + } else { 93 + $log->append($content); 94 + } 58 95 59 96 echo tsprintf( 60 97 "%s\n",
+1 -1
src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
··· 492 492 'UPDATE %T SET 493 493 chunk = CONCAT(chunk, %B), 494 494 size = %d, 495 - tailOffset = headOffset + %d, 495 + tailOffset = headOffset + %d 496 496 WHERE 497 497 id = %d', 498 498 $chunk_table,