runtime

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

OpenCloud: Runtime

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/opencloude-eu/opencloud/opencloud/pkg/runtime/service"

func main() {
    service.Start()
}

start runtime

Start sending messages message runtime

Example

package main

import (
	"fmt"
	"github.com/opencloud-eu/opencloud/opencloud/pkg/runtime/process"
	"github.com/opencloud-eu/opencloud/opencloud/pkg/runtime/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 example above with RUNTIME_KEEP_ALIVE=true and with no RUNTIME_KEEP_ALIVE set to see its behavior. It requires an OpenCloud binary present in your $PATH for it to work.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *Options)

Option undocumented

func Context

func Context(c *cli.Context) Option

Context option

func Services

func Services(s []string) Option

Services option

type Options

type Options struct {
	Services []string
	Logger   log.Logger
	Context  *cli.Context
}

Options is a runtime option

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime represents an OpenCloud runtime environment.

func New

func New(cfg *config.Config) Runtime

New creates a new OpenCloud + micro runtime

func (*Runtime) Start

func (r *Runtime) Start(ctx context.Context) error

Start rpc runtime

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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