All Projects → abiosoft → caddy-exec

abiosoft / caddy-exec

Licence: Apache-2.0 License
Caddy v2 module for running one-off commands

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to caddy-exec

souin
An HTTP cache system, RFC compliant, compatible with @TykTechnologies, @traefik, @caddyserver, @go-chi, @bnkamalesh, @beego, @devfeel, @labstack, @gofiber, @go-goyave, @gin-gonic, @zalando, @zeromicro, @nginx and @apache
Stars: ✭ 269 (+460.42%)
Mutual labels:  caddy, caddyserver, caddy-module
caddy-json-schema
JSON schema generator for Caddy v2
Stars: ✭ 63 (+31.25%)
Mutual labels:  caddy, caddyserver, caddy-module
vscode-caddyfile-support
Rich Caddyfile support for Visual Studio Code
Stars: ✭ 30 (-37.5%)
Mutual labels:  caddy, caddyserver
caddy-ratelimit
HTTP rate limiting module for Caddy 2
Stars: ✭ 72 (+50%)
Mutual labels:  caddy, caddy-module
caddy-authorize
Authorization Plugin for Caddy v2 (JWT/PASETO)
Stars: ✭ 235 (+389.58%)
Mutual labels:  caddy, caddy-module
ssss
Stupid Simple Seedbox Script
Stars: ✭ 19 (-60.42%)
Mutual labels:  caddy, caddyserver
coraza-caddy
OWASP Coraza middleware for Caddy. It provides Web Application Firewall capabilities
Stars: ✭ 75 (+56.25%)
Mutual labels:  caddy, caddyserver
caddy-tlsconsul
🔒 Consul K/V storage for Caddy Web Server / Certmagic TLS data
Stars: ✭ 89 (+85.42%)
Mutual labels:  caddy, caddyserver
Loginsrv
JWT login microservice with plugable backends such as OAuth2, Google, Github, htpasswd, osiam, ..
Stars: ✭ 1,835 (+3722.92%)
Mutual labels:  caddy, caddyserver
caddy-esi
Middleware for Caddy Server integrating ESI (edge side includes) tags with parallel loading. Able to connect to HTTP/S/2, Memcache, Redis, shell scripts, gRPC and SQL backends 🐜🐜🐜
Stars: ✭ 28 (-41.67%)
Mutual labels:  caddy, caddyserver
caddy-crowdsec-bouncer
A Caddy module that blocks malicious traffic based on decisions made by CrowdSec.
Stars: ✭ 40 (-16.67%)
Mutual labels:  caddy, caddyserver
caddygit
Git module for Caddy v2
Stars: ✭ 67 (+39.58%)
Mutual labels:  caddy, caddy-module
vscode-terminals
An extension for setting-up multiple terminals at once, or just running some commands.
Stars: ✭ 83 (+72.92%)
Mutual labels:  command
docker-v2ray
A docker-compose deployment for v2ray + WebSocket + TLS setup.
Stars: ✭ 30 (-37.5%)
Mutual labels:  caddy
command help
ℹ️ Extract help text from builtin commands and man pages
Stars: ✭ 54 (+12.5%)
Mutual labels:  command
cli
Aplus Framework CLI Library
Stars: ✭ 104 (+116.67%)
Mutual labels:  command
impress-cli
Impress Application Server Command line interface
Stars: ✭ 25 (-47.92%)
Mutual labels:  command
caddy-scratch
Caddy server 2.0.0 / 1.0.5 on Docker Scratch, all in 18MB / 35MB
Stars: ✭ 32 (-33.33%)
Mutual labels:  caddy
Dockers
https://hub.docker.com/r/chenhw2/
Stars: ✭ 42 (-12.5%)
Mutual labels:  caddy
WCMP
WCMP是基于Windows x64平台下的Caddy2 + PHP + MySQL便携软件包。
Stars: ✭ 17 (-64.58%)
Mutual labels:  caddy

caddy-exec

Caddy v2 module for running one-off commands.

Installation

xcaddy build \
    --with github.com/abiosoft/caddy-exec

Usage

Commands can be configured to be triggered globally during startup/shutdown or by via a route.

They can also be configured to run in the background or foreground and to be terminated after a timeout.

⚠️ startup commands running on foreground will prevent Caddy from starting if they exit with an error.

Caddyfile

exec [<matcher>] [<command> [<args...>]] {
    command     <command> [<args...>]
    args        <args...>
    directory   <directory>
    timeout     <timeout>
    log         <log output module>
    err_log     <log output module>
    foreground
    startup
    shutdown
}
  • matcher - Caddyfile matcher. When set, this command runs when there is an http request at the current route or the specified matcher. You may leverage other matchers to protect the endpoint.
  • command - command to run
  • args... - command arguments
  • directory - directory to run the command from
  • timeout - timeout to terminate the command's process. Default is 10s. A timeout of 0 runs indefinitely.
  • log - Caddy log output module for standard output log. Defaults to stderr.
  • err_log - Caddy log output module for standard error log. Defaults to the value of log (standard output log).
  • foreground - if present, runs the command in the foreground. For commands at http endpoints, the command will exit before the http request is responded to.
  • startup - if present, run the command at startup. Ignored in routes.
  • shutdown - if present, run the command at shutdown. Ignored in routes.

Example

exec can run at start via the global directive.

{
  exec hugo generate --destination=/home/user/site/public {
      timeout 0 # don't timeout
  }
}

exec can be the last action of a route block.

route /update {
    ... # other directives e.g. for authentication
    exec git pull origin master {
        log file /var/logs/hugo.log
    }
}

API/JSON

As a top level app for startup and shutdown commands.

{
  "apps": {
    "http": { ... },
    // app configuration
    "exec": {
      // list of commands
      "commands": [
        // command configuration
        {
          // command to execute
          "command": "hugo",
          // [optional] command arguments
          "args": [
            "generate",
            "--destination=/home/user/site/public"
          ],
          // when to run the command, can include 'startup' or 'shutdown'
          "at": ["startup"],

          // [optional] directory to run the command from. Default is the current directory.
          "directory": "",
          // [optional] if the command should run on the foreground. Default is false.
          "foreground": false,
          // [optional] timeout to terminate the command's process. Default is 10s.
          "timeout": "10s",
          // [optional] log output module config for standard output. Default is `stderr` module.
          "log": {
            "output": "file",
            "filename": "/var/logs/hugo.log"
          },
          // [optional] log output module config for standard error. Default is the value of `log`.
          "err_log": {
            "output": "stderr"
          }
        }
      ]
    }
  }
}

As an handler within a route.

{
  ...
  "routes": [
    {
      "handle": [
        // exec configuration for an endpoint route
        {
          // required to inform caddy the handler is `exec`
          "handler": "exec",
          // command to execute
          "command": "git",
          // command arguments
          "args": ["pull", "origin", "master"],

          // [optional] directory to run the command from. Default is the current directory.
          "directory": "/home/user/site/public",
          // [optional] if the command should run on the foreground. Default is false.
          "foreground": true,
          // [optional] timeout to terminate the command's process. Default is 10s.
          "timeout": "5s",
          // [optional] log output module config for standard output. Default is `stderr` module.
          "log": {
            "output": "file",
            "filename": "/var/logs/hugo.log"
          },
          // [optional] log output module config for standard error. Default is the value of `log`.
          "err_log": {
            "output": "stderr"
          }
        }
      ],
      "match": [
        {
          "path": ["/update"]
        }
      ]
    }
  ]
}

Dynamic Configuration

Caddy supports dynamic zero-downtime configuration reloads and it is possible to modify exec's configurations at runtime.

exec intelligently determines when Caddy is starting and shutting down. i.e. startup and shutdown commands do not get triggered during configuration reload, only during Caddy's actual startup and shutdown.

License

Apache 2

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].