- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更新:
随着@Tanktalus 的回答,我意识到它是最左边的 kubectl
命令被缓冲。
# will hang forever, because RHS pipe is broken, and LHS pipe need to send
# the output to the pipe to realize the broken pipe, but as the buffer is
# never filled, it's never broken
kubectl logs -f pod -n NAMESPACE | grep -q "Indicator"
# put LHS to the background, because I don't care if it hang, I just need the log.
(kubectl logs -f pod -n NAMESPACE &) | grep -q "Indicator"
(kubectl logs -f pod -n NAMESPACE &)| tee log >(grep -q "Indicator")
sleep infinity
.所以日志仍然会被流式传输,但不会提供新的输出。
|
重定向我的 kubernetes 的流式日志,然后 grep 日志的每一行,直到找到“指示器”,然后我想(立即)退出。我尝试过的命令如下:
# none of them worked, they all show the Indicator line, and then hangs forever.
kubectl logs -f pod -n NAMESPACE | tee test.log >(grep -q "Indicator")
stdbuf -o 0 kubectl logs -f pod -n NAMESPACE | tee test.log >(grep -m1 "Indicator")
stdbuf -o 0 kubectl logs -f pod -n NAMESPACE | tee test.log >(grep -q --line-buffered "Indicator")
stdbuf -o 0 kubectl logs -f pod -n NAMESPACE | grep -q --line-buffered "Indicator"
最佳答案
我怀疑是因为kubectl
没有退出,shell 没有继续。如果您查看 ps
输出,你会注意到 grep -m1 ...
实际上确实退出了,并且不再存在,但管道的其余部分仍然存在。
所以我怀疑你需要颠倒这个。例如,在 perl 中,我会使用 open
打开到 kubectl 的管道,读取输出,直到找到我想要的,杀死 child ,然后退出。在 C 中,与 popen
相同。 .我不确定 bash 是否提供了相当程度的控制。
例如:
perl -E 'my $pid = open my $fh, "-|", qw(perl -E), q($|++; say for 1..10; say "BOOM"; say "Sleep Infinity"; sleep 50) or die "Cannot run: $!"; while(<$fh>) { if (/BOOM/) { say; kill "INT", $pid; exit 0 } }'
open
中的内容在
"-|"
之后使用您自己的命令和
if (/BOOM/)
使用您自己的正则表达式,否则它应该可以工作。
关于bash - grep 从超慢连续流式日志中找到,一旦找到没有缓冲区的字符串就退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54356952/
在C#中,我可以通过base关键字访问基类,在java中,我可以通过super关键字访问它。在delphi中如何做到这一点?假设我有以下代码: type TForm3 = class(TF
在这件事上我已经把头撞到墙上好几次了。所以我希望在正确的方向上得到一点帮助。 我有一张 table ,上面有订单,一张 table 上有火车,一张 table 上有航类,一张 table 上有巴士。每
在 Python 中,假设我有以下代码: class SuperClass(object): def __init__(self, x): self.x = x
我希望这个 subview 扩展到它的父 View 之外,但是父 View 的边框正在切入 subview 。有没有办法防止这种情况? class TheView : UIView { let
我有一个标准的高斯函数,看起来像这样: def gauss_fnc(x, amp, cen, sigma): return amp * np.exp(-(x - cen) ** 2 / (2
例如,我有下一个类,带有有界类型参数: public class ItemContainer { void addItems(List items); } 在另一个带有参数的类中使用: pub
如何将此设置转换为命令? 结果如下: // Manual Compression (see the image above) Compressed Size: 12,647,451 bytes //
请建议在应用继承时如何使用@Wither/@With。 我有一个抽象类Parent和具体的Child。 Child 应该是不可变的。将 @Wither 放在两者上会给我两个错误: 构造函数 Child
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我正在尝试向服务器(虚拟托管)发出 HTTP2 请求,该服务器根据主机 header 值 (SNI) 提供 SSL 证书。 # conn = hyper.HTTP20Connection('h
我有一个应用程序,必须将大约 1300 万行、大约 10 个平均长度的字符串插入到嵌入式 HSQLDB 中。我一直在调整一些东西(批量大小、单线程/多线程、缓存/非缓存表、MVCC 事务、log_si
我想定义一个函数f(x, t::Type)根据 isa(x, t) 是否执行不同的行为.假设我想调用b1(x)如果是,b2(x)除此以外。 我知道我可以像这样在运行时进行动态检查: function
我正在使用 Hyper-V WMI Provider在 Hyper-V 中导入虚拟机,特别是使用 ImportVirtualSystemEx Msvm_VirtualSystemManagementS
这几个星期以来一直困扰着我,我没有结束对它的研究,因为我目前重载并且它让我落后于第一年的 CS (opengl) 大学类(class),这首先让我研究了这个:如何只用一个 for 循环绘制立方体的所有
我正在我的计算机(操作系统:Windows 8)上开发一个 WP8 应用程序。我需要安装一个 VM 才能拥有 linux。同时我需要使用我的 Windows Phone 模拟器。 我下载了 VMWar
我是一名优秀的程序员,十分优秀!