mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
[client] Do not run up cmd if not needed in docker (#4508)
optimizes the NetBird client startup process by avoiding unnecessary login commands when the peer is already authenticated. The changes increase the default login timeout and expand the log message patterns used to detect successful authentication. - Increased default login timeout from 1 to 5 seconds for more reliable authentication detection - Enhanced log pattern matching to detect both registration and ready states - Added extended regex support for more flexible pattern matching
This commit is contained in:
@@ -18,7 +18,7 @@ ENV \
|
|||||||
NB_LOG_FILE="console,/var/log/netbird/client.log" \
|
NB_LOG_FILE="console,/var/log/netbird/client.log" \
|
||||||
NB_DAEMON_ADDR="unix:///var/run/netbird.sock" \
|
NB_DAEMON_ADDR="unix:///var/run/netbird.sock" \
|
||||||
NB_ENTRYPOINT_SERVICE_TIMEOUT="5" \
|
NB_ENTRYPOINT_SERVICE_TIMEOUT="5" \
|
||||||
NB_ENTRYPOINT_LOGIN_TIMEOUT="1"
|
NB_ENTRYPOINT_LOGIN_TIMEOUT="5"
|
||||||
|
|
||||||
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
|
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
set -eEuo pipefail
|
set -eEuo pipefail
|
||||||
|
|
||||||
: ${NB_ENTRYPOINT_SERVICE_TIMEOUT:="5"}
|
: ${NB_ENTRYPOINT_SERVICE_TIMEOUT:="5"}
|
||||||
: ${NB_ENTRYPOINT_LOGIN_TIMEOUT:="1"}
|
: ${NB_ENTRYPOINT_LOGIN_TIMEOUT:="5"}
|
||||||
NETBIRD_BIN="${NETBIRD_BIN:-"netbird"}"
|
NETBIRD_BIN="${NETBIRD_BIN:-"netbird"}"
|
||||||
export NB_LOG_FILE="${NB_LOG_FILE:-"console,/var/log/netbird/client.log"}"
|
export NB_LOG_FILE="${NB_LOG_FILE:-"console,/var/log/netbird/client.log"}"
|
||||||
service_pids=()
|
service_pids=()
|
||||||
@@ -39,7 +39,7 @@ wait_for_message() {
|
|||||||
info "not waiting for log line ${message@Q} due to zero timeout."
|
info "not waiting for log line ${message@Q} due to zero timeout."
|
||||||
elif test -n "${log_file_path}"; then
|
elif test -n "${log_file_path}"; then
|
||||||
info "waiting for log line ${message@Q} for ${timeout} seconds..."
|
info "waiting for log line ${message@Q} for ${timeout} seconds..."
|
||||||
grep -q "${message}" <(timeout "${timeout}" tail -F "${log_file_path}" 2>/dev/null)
|
grep -E -q "${message}" <(timeout "${timeout}" tail -F "${log_file_path}" 2>/dev/null)
|
||||||
else
|
else
|
||||||
info "log file unsupported, sleeping for ${timeout} seconds..."
|
info "log file unsupported, sleeping for ${timeout} seconds..."
|
||||||
sleep "${timeout}"
|
sleep "${timeout}"
|
||||||
@@ -81,7 +81,7 @@ wait_for_daemon_startup() {
|
|||||||
login_if_needed() {
|
login_if_needed() {
|
||||||
local timeout="${1}"
|
local timeout="${1}"
|
||||||
|
|
||||||
if test -n "${log_file_path}" && wait_for_message "${timeout}" 'peer has been successfully registered'; then
|
if test -n "${log_file_path}" && wait_for_message "${timeout}" 'peer has been successfully registered|management connection state READY'; then
|
||||||
info "already logged in, skipping 'netbird up'..."
|
info "already logged in, skipping 'netbird up'..."
|
||||||
else
|
else
|
||||||
info "logging in..."
|
info "logging in..."
|
||||||
|
|||||||
Reference in New Issue
Block a user