pman

command module
v0.0.0-...-7406747 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 3 Imported by: 0

README

ownCloud Infinite Scale: Runtime

Codacy Badge Go Reference Release

Pman is a slim utility library for supervising long-running processes. It can be embedded or used as a cli command.

When used as a CLI command it relays actions to a running runtime.

Usage

Start a runtime

package main
import "github.com/refs/pman/pkg/service"

func main() {
    service.Start()    
}

start runtime

Start sending messages message runtime

Example

package main

import (
	"fmt"
	"github.com/refs/pman/pkg/process"
	"github.com/refs/pman/pkg/service"
	"github.com/rs/zerolog/log"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func main() {
	s := service.NewService()
	var c = make(chan os.Signal, 1)
	var o int

	signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
	if err := s.Start(process.NewProcEntry("ocs", nil, "ocs"), &o); err != nil {
		os.Exit(1)
	}

	time.AfterFunc(3*time.Second, func() {
		var acc = "ocs"
		fmt.Printf(fmt.Sprintf("shutting down service: %s", acc))
		if err := s.Controller.Kill(&acc); err != nil {
			log.Fatal()
		}
		os.Exit(0)
	})

	for {
		select {
		case <-c:
			return
		}
	}
}

Run the above example with RUNTIME_KEEP_ALIVE=true and with no RUNTIME_KEEP_ALIVE set to see its behavior. It requires an OCIS binary present in your $PATH for it to work.

Security

If you find a security issue please contact hello@zyxan.io ffirst.

Contributing

Fork -> Patch -> Push -> Pull Request

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
cmd
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL