Skip to content

Instantly share code, notes, and snippets.

@s8508235
s8508235 / tcplife.sh
Created March 18, 2021 09:05
tcplife a command
#! /bin/bash
# I don't know it's correct or not; at least it works for me.
{YOUR_COMMAND} & # make sure your command will end
pid=$!
kill -s STOP ${pid}
sudo stdbuf -oL tcplife -p ${pid} -s > otuput.csv &
tcplife_pid=$!
sleep 5
kill -s CONT ${pid}
wait ${pid}
@s8508235
s8508235 / gracefully_shutdown_server.go
Last active January 18, 2024 21:01
gracefully shutdown go web server with error group
package main
import (
"context"
"fmt"
"net/http"
"os/signal"
"syscall"
"time"