remotecommandhttpserver

package module
v0.0.0-...-c6303ee Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 16 Imported by: 0

README

Server to simply execute commands via http

This server executes commands written in YAML via HTTP. The stdout and stderr of the command are writen in real time.

Use this when you want to separate the environment in which commands are sent and the environment in which they are executed.

command-server ./config.yaml -p 8080
curl --no-buffer http://command-server-host:8080/call1
🇯🇵

http経由でコマンドを単純に実行するサーバ

YAML に書いたコマンドを、HTTP経由で実行するサーバです。コマンドの標準出力、標準エラー出力を、リアルタイムに返却します。

コマンドを送信する環境と、実行する環境を分けたい場合に利用する。

config

max_concurrency: 10
cmds:
  - path: /call1
    cwd: .
    cmd:
      - go
      - run
      - ./testdata/call/main.go
      - call1
    env_file: "./testdata/call1.env"
  - path: /call2
    cmd:
      - go
      - run
      - ./call/main.go
      - call2
    cwd: ./testdata
    envs:
      ENV_VAR: env_var_vall2
  - path: /{id}/call3
    cmd:
      - go
      - run
      - ./call/main.go
      - call3-{id}
    cwd: ./testdata
    envs:
      ENV_VAR: env_var_vall2
  - path: /env
    cmd:
      - /usr/bin/env
    envs:
      ENV_VAR: env_var_vall2

install

Download from release page https://github.com/74th/remote-command-http-server/releases/latest

go install github.com/74th/remote-command-http-server@latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCommandExited = fmt.Errorf("command exited")
View Source
var ErrCommandExitedWithError = fmt.Errorf("command exited with error")

Functions

This section is empty.

Types

type CmdConfig

type CmdConfig struct {
	Path     string            `json:"path" yaml:"path"`
	Cmd      []string          `json:"cmd" yaml:"cmd"`
	Cwd      string            `json:"cwd,omitempty" yaml:"cwd,omitempty"`
	Envs     map[string]string `json:"envs,omitempty" yaml:"envs,omitempty"`
	EnvFile  string            `json:"env_file,omitempty" yaml:"env_file,omitempty"`
	PathArgs []PathArgs
}

type Config

type Config struct {
	MaxConcurrency int         `json:"max_concurrency,omitempty" yaml:"max_concurrency,omitempty"`
	Cmds           []CmdConfig `json:"cmds" yaml:"cmds"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

type PathArgs

type PathArgs struct {
	Name        string
	PlaceHolder string
}

type Server

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

func NewServer

func NewServer(addr string, configPath string) (*Server, error)

func (*Server) List

func (s *Server) List(res http.ResponseWriter, req *http.Request)

func (*Server) ServeCall

func (s *Server) ServeCall(res http.ResponseWriter, req *http.Request, cmd *CmdConfig)

func (*Server) Shoutdown

func (s *Server) Shoutdown() error

func (*Server) Start

func (s *Server) Start() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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