go-zero/core/proc/process.go

27 lines
347 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package proc
import (
"os"
"path/filepath"
)
var (
procName string
pid int
)
func init() {
procName = filepath.Base(os.Args[0])
pid = os.Getpid()
}
2021-02-22 10:07:39 +08:00
// Pid returns pid of current process.
2020-07-26 17:09:05 +08:00
func Pid() int {
return pid
}
2021-02-22 10:07:39 +08:00
// ProcessName returns the processname, same as the command name.
2020-07-26 17:09:05 +08:00
func ProcessName() string {
return procName
}