Giter Club home page Giter Club logo

gorun's Introduction

简易命令执行服务

这是一个用 Go 编写的简易命令执行服务。它允许您通过 HTTP 请求执行命令,并提供了用于检查已执行命令和获取统计信息的端点。

功能

  • 执行命令: 发送 POST 请求到 /run,请求体中包含要执行的命令。
  • 获取已执行命令统计信息: 发送 GET 请求到 /stats 获取已执行命令的统计信息。
  • 服务信息: 发送请求到 / 获取有关可用端点的信息。

部署

  1. 克隆仓库:

    git clone https://github.com/sunbooshi/gorun.git
    cd gorun
  2. 配置白名单: 编辑 /usr/local/etc/gorun.conf 文件,指定允许的命令白名单,每行一个命令。

  3. 构建并运行:

    go build
    ./gorun -port=8080

    8080 替换为所需的端口号。

  4. 访问服务: 服务将在 http://localhost:8080 处可访问。您可以向指定的端点发送 HTTP 请求。

权限

日志文件权限

如果在日志文件 (/var/log/gorun.log) 上遇到权限问题,请确保运行服务的用户具有写入此文件的必要权限。您可能需要手动创建日志文件并调整其权限。

示例:

touch /var/log/gorun.log
chmod 666 /var/log/gorun.log

端口绑定

如果选择的端口号低于 1024(例如,80),您可能需要超级用户权限才能绑定到该端口。考虑使用高于 1024 的端口号,或者根据需要以提升的权限运行服务。

贡献者

  • ChatGPT

后记

这是完全由 ChatGPT 生成的代码,我只是把自己的需求描述了一下。然后不停的改进,ChatGPT几乎是完全理解了我的需求。虽然我已经知道ChatGPT很强了,但这个项目还是让我小小的震撼了一下。是时候改变自己的编程习惯了,拥抱ChatGPT。

我会把这个服务部署到我的FreeBSD上,然后在BT下载完成后会通过这个服务来执行同步命令,把下载机上的文件同步到NAS服务器上。

gorun's People

Contributors

sunbooshi avatar

Stargazers

小宇宇 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.