test better shutdown nfstream
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s
This commit is contained in:
@@ -60,6 +60,7 @@ class BackendSettings:
|
|||||||
nfstream_active_timeout_seconds: int
|
nfstream_active_timeout_seconds: int
|
||||||
nfstream_snapshot_length: int
|
nfstream_snapshot_length: int
|
||||||
nfstream_n_dissections: int
|
nfstream_n_dissections: int
|
||||||
|
nfstream_n_meters: int
|
||||||
nfstream_cache_ttl_seconds: float
|
nfstream_cache_ttl_seconds: float
|
||||||
nfstream_lookup_window_ms: int
|
nfstream_lookup_window_ms: int
|
||||||
nfstream_reader_join_timeout_seconds: float
|
nfstream_reader_join_timeout_seconds: float
|
||||||
@@ -97,6 +98,7 @@ def load_settings() -> BackendSettings:
|
|||||||
nfstream_active_timeout_seconds=_env_int("BACKEND_NFSTREAM_ACTIVE_TIMEOUT_SECONDS", 1800),
|
nfstream_active_timeout_seconds=_env_int("BACKEND_NFSTREAM_ACTIVE_TIMEOUT_SECONDS", 1800),
|
||||||
nfstream_snapshot_length=_env_int("BACKEND_NFSTREAM_SNAPSHOT_LENGTH", 1536),
|
nfstream_snapshot_length=_env_int("BACKEND_NFSTREAM_SNAPSHOT_LENGTH", 1536),
|
||||||
nfstream_n_dissections=_env_int("BACKEND_NFSTREAM_N_DISSECTIONS", 20),
|
nfstream_n_dissections=_env_int("BACKEND_NFSTREAM_N_DISSECTIONS", 20),
|
||||||
|
nfstream_n_meters=_env_int("BACKEND_NFSTREAM_N_METERS", 1),
|
||||||
nfstream_cache_ttl_seconds=_env_float("BACKEND_NFSTREAM_CACHE_TTL_SECONDS", 10.0),
|
nfstream_cache_ttl_seconds=_env_float("BACKEND_NFSTREAM_CACHE_TTL_SECONDS", 10.0),
|
||||||
nfstream_lookup_window_ms=_env_int("BACKEND_NFSTREAM_LOOKUP_WINDOW_MS", 5_000),
|
nfstream_lookup_window_ms=_env_int("BACKEND_NFSTREAM_LOOKUP_WINDOW_MS", 5_000),
|
||||||
nfstream_reader_join_timeout_seconds=_env_float("BACKEND_NFSTREAM_READER_JOIN_TIMEOUT_SECONDS", 2.0),
|
nfstream_reader_join_timeout_seconds=_env_float("BACKEND_NFSTREAM_READER_JOIN_TIMEOUT_SECONDS", 2.0),
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ def main() -> int:
|
|||||||
parser.add_argument("--active-timeout", type=int, required=True)
|
parser.add_argument("--active-timeout", type=int, required=True)
|
||||||
parser.add_argument("--snapshot-length", type=int, required=True)
|
parser.add_argument("--snapshot-length", type=int, required=True)
|
||||||
parser.add_argument("--n-dissections", type=int, required=True)
|
parser.add_argument("--n-dissections", type=int, required=True)
|
||||||
|
parser.add_argument("--n-meters", type=int, required=True)
|
||||||
parser.add_argument("--promiscuous-mode", action="store_true")
|
parser.add_argument("--promiscuous-mode", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ def main() -> int:
|
|||||||
idle_timeout=args.idle_timeout,
|
idle_timeout=args.idle_timeout,
|
||||||
active_timeout=args.active_timeout,
|
active_timeout=args.active_timeout,
|
||||||
n_dissections=args.n_dissections,
|
n_dissections=args.n_dissections,
|
||||||
|
n_meters=args.n_meters,
|
||||||
statistical_analysis=False,
|
statistical_analysis=False,
|
||||||
accounting_mode=0,
|
accounting_mode=0,
|
||||||
udps=EmitFlowMetadata(),
|
udps=EmitFlowMetadata(),
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ class NFStreamManager:
|
|||||||
str(settings.nfstream_snapshot_length),
|
str(settings.nfstream_snapshot_length),
|
||||||
"--n-dissections",
|
"--n-dissections",
|
||||||
str(settings.nfstream_n_dissections),
|
str(settings.nfstream_n_dissections),
|
||||||
|
"--n-meters",
|
||||||
|
str(settings.nfstream_n_meters),
|
||||||
]
|
]
|
||||||
if settings.nfstream_promiscuous_mode:
|
if settings.nfstream_promiscuous_mode:
|
||||||
cmd.append("--promiscuous-mode")
|
cmd.append("--promiscuous-mode")
|
||||||
@@ -198,6 +200,7 @@ class NFStreamManager:
|
|||||||
text=True,
|
text=True,
|
||||||
bufsize=1,
|
bufsize=1,
|
||||||
env=env,
|
env=env,
|
||||||
|
start_new_session=True,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Failed to start NFStream worker for %s", iface)
|
logger.exception("Failed to start NFStream worker for %s", iface)
|
||||||
@@ -226,10 +229,13 @@ class NFStreamManager:
|
|||||||
|
|
||||||
if process is not None and process.poll() is None:
|
if process is not None and process.poll() is None:
|
||||||
try:
|
try:
|
||||||
process.send_signal(signal.SIGTERM)
|
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
||||||
process.wait(timeout=settings.nfstream_process_stop_timeout_seconds)
|
process.wait(timeout=settings.nfstream_process_stop_timeout_seconds)
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
process.kill()
|
try:
|
||||||
|
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
||||||
|
except ProcessLookupError:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Failed to stop NFStream worker for %s cleanly", iface)
|
logger.exception("Failed to stop NFStream worker for %s cleanly", iface)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user