...

Package debug

import "github.com/Diarkis/diarkis/debug"
Overview
Index

Overview ▾

Package debug ▷

Diarkis is equipped with debug tools to aid your development.

Change log level in runtime

By sending SIGUSR1 to Diarkis server process, you may change logging level without interrupting the server process.

Every time you send SIGUSR1 signal, it changes the log level.

Below is the order of log level change:

   ╭─────────╮ ╭─────────╮ ╭─────────╮ ╭─────────╮ ╭─────────╮
╔═▶︎│ Verbose │▶︎│ Network │▶︎│   Sys   │▶︎│  Debug  │▶︎│   Info  │══╗
║  ╰─────────╯ ╰─────────╯ ╰─────────╯ ╰─────────╯ ╰─────────╯  ║
╚═══════════════════════════════════════════════════════════════╝

1. Create a file /tmp/DIARKIS_SIGSUR1

2. Write LogLevelChange into the /tmp/DIARKIS_SIGUSR1 file

3. Send SIGUSR1 signal by executing kill -s SIGUSR1 $(PID)

Enable or Disable pprof in runtime

By sending SIGUSR1 to Diarkis server process, you may toggle pprof without interrupting the server process.

Every time you send SIGUSR1 signal it enable/disable pprof.

1. Create a file /tmp/DIARKIS_SIGSUR1

2. Write Debug into the /tmp/DIARKIS_SIGUSR1 file

3. Send SIGUSR1 signal by executing kill -s SIGUSR1 $(PID)

▶︎ How to use profiler

When debug pprof is enabled, the server opens 127.0.0.1:6060/debug/pprof endpoint:

Profile CPU usage:

curl 127.0.0.1:6060/debug/pprof/profile > cpu.profile

Read CPU profile:

go tool pprof cpu.profile

Profile memory allocation:

curl 127.0.0.1:6060/debug/pprof/heap > heap.profile

Read memory allocation profile:

go tool pprof heap.profile

Trace:

curl 127.0.0.1:6060/debug/pprof/trace > trace.profile

Read trace profile:

go tool trace trace.profile

Dump currently held user, room, and group data into stdout stream

By sending SIGUSR1 to Diarkis server process, you may dump the said data without interrupting the server process.

1. Create a file /tmp/DIARKIS_SIGUSR1

2. Write VaultDump into the /tmp/DIARKIS_SIGUSR1 file

3. Send SIGUSR1 signal by executing kill -s SIGUSR1 $(PID)

Dump MatchMaker Data

By sending SIGUSR1 to Diarkis server process, you may dump the MatchMaker data into stdout stream.

1. Create a file /tmp/DIARKIS_SIGUSR1

2. Write MatchMakerDump into the /tmp/DIARKIS_SIGUSR1 file

3. Send SIGUSR1 signal by executing kill -s SIGUSR1 $(PID)

func Disable

func Disable()

Disable Turns off debug functions

func Enable

func Enable()

Enable Turns on debug functions

func IsEnabled

func IsEnabled() bool

IsEnabled returns true, if debug.Enable() has been called

func RunMemoryWatch

func RunMemoryWatch()

RunMemoryWatch Reads memory usage statistics and outputs them to stdout stream