github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state-exec/heartbeat.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"strconv"
     7  
     8  	"github.com/ActiveState/cli/internal/svcctl/svcmsg"
     9  )
    10  
    11  func newHeartbeat() (*svcmsg.Heartbeat, error) {
    12  	execPath, err := os.Executable()
    13  	if err != nil {
    14  		return nil, fmt.Errorf("cannot get executable info: %w", err)
    15  	}
    16  	pid := strconv.Itoa(os.Getpid())
    17  	hb := svcmsg.NewHeartbeat(pid, execPath)
    18  
    19  	return hb, nil
    20  }