Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the pit in the while read loop that calls ssh remote execution code?

Shulou Source: shulou.com Published: 2022-06-01 02:41:27 10月03日 Update

What this article shares to you is about the big pit of calling ssh remote execution code in the while read cycle. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Then began to investigate why it was cut so slowly.

Then start the balabala code log and find that if the test is normal or does not meet the lvs switching standard, the whole code flow can be completed.

Start the balabala code against the log. Then suddenly discover the code structure of the while read loop calling ssh to the remote execution.

The problem here is if you read each node in while read and then check the corresponding health status of that node.

If this node needs to be switched by lvs. Then call ssh to a remote node to execute an operation command.

Execute this ssh because ssh takes stdin as input. So I read all the stdin buffer of while read.

Cause this node to finish processing, while loop, and then start from scratch, read has reached EOF. Then the loop exits.

If this node does not meet the switching criteria, ok, it will not call ssh. Then the latter node is still in the stdin buffer of while read.

Read can read it. Then the whole cycle will run out.

After we take over, it will be very convenient to trace the source of the problem. Of course。 The problem is thus solved.

This is what the big pit of calling ssh remote execution code in the while read loop is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Node code loop time problem switch big pit that is log more standard knowledge article test practical healthy not enough from scratch command done Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia MariaDB Docker vpn