Skip to content

Instantly share code, notes, and snippets.

@regiellis
Last active October 11, 2024 17:11
Show Gist options
  • Save regiellis/44989e4446aebea39e724c6204904e74 to your computer and use it in GitHub Desktop.
Save regiellis/44989e4446aebea39e724c6204904e74 to your computer and use it in GitHub Desktop.
Invoke Service
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
(cors) {
@cors_preflight method OPTIONS
@cors header Origin {args.0}
handle @cors_preflight {
header Access-Control-Allow-Origin "{args.0}"
header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE"
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Max-Age "3600"
respond "" 204
}
handle @cors {
header Access-Control-Allow-Origin "{args.0}"
header Access-Control-Expose-Headers "Link"
}
}
# Global HTTPS configuration
{
# Optional: Configure automatic HTTPS
auto_https disable_redirects
}
:80, :444 {
# Set this path to your site's directory.
#root * /usr/share/caddy
# Enable the static file server.
#file_server
# Another common task is to set up a reverse proxy:
reverse_proxy 127.0.0.1:80
}
#advanced
http://invoke.playhub.local {
tls internal
import cors https://invoke.playhub.local # update with your local url
#header {
# Content-Security-Policy "upgrade-insecure-requests"
#} # mixed-content
reverse_proxy 127.0.0.1:9090 {
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Port {server_port}
header_up X-Forwarded-Proto {scheme}
}
#simple...
invoke.playhub.local {
tls internal
reverse_proxy 127.0.0.1:9090
}
include /etc/caddy/caddyfiles/*
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
#!/bin/bash
set -eu
# Ensure we're in the correct folder in case user's CWD is somewhere else
scriptdir=$(dirname "$0")
cd "$scriptdir"
. .venv/bin/activate
export INVOKEAI_ROOT="$scriptdir"
# Stash the CLI args - when we prompt for user input, `$@` is overwritten
PARAMS=$@
# This setting allows torch to fall back to CPU for operations that are not supported by MPS on macOS.
if [ "$(uname -s)" == "Darwin" ]; then
export PYTORCH_ENABLE_MPS_FALLBACK=1
fi
invokeai-web
[Unit]
Description=Invoke script
After=network.target
[Service]
User=playlogic
ExecStart=/mnt/Hub/AI/INVOKEAI/invoke-web.sh # make sure to update this with your path
Restart=on-success
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment