siked f29d3fc0bc master 11 months ago
..
config f29d3fc0bc master 11 months ago
context f29d3fc0bc master 11 months ago
ctl f29d3fc0bc master 11 months ago
service f29d3fc0bc master 11 months ago
README.MD f29d3fc0bc master 11 months ago
RunCode.go f29d3fc0bc master 11 months ago
打包镜像.MD f29d3fc0bc master 11 months ago

README.MD

Cloud-Run-Code

在线运行代码 服务依赖docker环境

    go run main.go --port=端口号 --config=配置文件路径

手动其他添加语言

编辑docker_config.json文件 添加对应 key value 即可

{
  "docker_runner": {
    "go": {
      "ext": "go",
      "filename": "main.go",
      "image": "golang:1.18.0-alpine3.15",
      "cmd": "go run main.go"
    }  
  }  
}

docker_runner字段说明

字段名 说明
ext 文件后续
filename 容器中运行的文件名
image 镜像名
cmd 启动容器后运行的命令

接口说明

获取所有支持的语言列表

GET /languages

[
  "go",
  "python",
  "php",
  "java",
  "node"
]

POST /run?lang={lang}

  • 参数说明 lang : 为 languages 接口返回的列表
  • 请求体:具体代码

    {
    "lang": "{lang}",
    "message": "execute success",
    "result": "hello world"
    }
    

Ubuntu

Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

sudo vim /etc/default/grub 替换: GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1" sudo update-grub reboot