Last active
November 20, 2015 14:33
-
-
Save stpettersens/1320e6c410a64c9f446b to your computer and use it in GitHub Desktop.
Wrapper script for Caddy server (shell script and Caddyfile to use with it).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
############################################################################ | |
# Run Caddy for the current working directory as a daemon using daemonize. | |
# Place in serving root. | |
# | |
# Prerequisites: | |
# * caddy installed to /opt/caddy/caddy (http://caddyserver.com) | |
# * daemonize (http://software.clapper.org/daemonize) | |
# | |
# Just run: ./caddy.sh (chmod +x caddy.sh before first run). | |
# Check server is running with: ps -e | grep caddy | |
############################################################################ | |
daemonize -c $(pwd) /opt/caddy/caddy | |
echo "Started Caddy server for" $(pwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Serve to outside world on port 2015. | |
0.0.0.0:2015 | |
# This rewrite stops caddy.sh being served. | |
rewrite { | |
regexp caddy\.sh | |
to / | |
} |
Also, Caddy may restart which changes its process id. Does that affect daemonize?
- Yes, alternatively you can see put it above and set the root in the Caddyfile, right? (would then need to tweak the $(pwd) part, but no problem).
- If the process ID changes that doesn't affect demonize, because its not quite the same as running a service from what I understand. Just now I just kill Caddy with its PID which might change admittedly.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably best to just not put caddy.sh in your site 😉