web-rpc

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

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

web-rpc

通过 web 接口远程执行命令, 用于解决容器内部需要调用宿主机命令的情况

启动命令

go run main.go web -c config.json

调用

curl --location --request POST 'localhost:8080/api/rpc/v1/run/reloadNginx'

配置

commands

  • code: 命令代码
  • exec: 具体命令字符串

编译

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/web-rpc-linux .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o build/web-rpc-darwin .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o build/web-rpc.exe .

开机启动

/etc/systemd/system/web-rpc.service

[Unit]
Description=web rpc Service
After=network.target

[Service]
Type=web-rpc
ExecStart=/usr/bin/web-rpc web -c /etc/web-rpc/config.json
User=root

[Install]
WantedBy=multi-user.target

查看日志:

journalctl -u web-rpc

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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