forked from caddyserver/caddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update macOS launchd example (caddyserver#1600)
* update to match same paths as systemd * update to match new launchd plist * generated from scratch with LaunchControl, flawless Had some issues with the previous go and found LaunchControl which made it easy to generate a perfectly correct launchd conf * Update README.md
- Loading branch information
Showing
2 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,42 @@ | ||
launchd service for macOS | ||
========================= | ||
|
||
This is a sample file for a *launchd* service on Mac. | ||
Edit the paths and email in the plist file to match your info. | ||
This is a working sample file for a *launchd* service on Mac, which should be placed here: | ||
|
||
```bash | ||
/Library/LaunchDaemons/com.caddyserver.web.plist | ||
``` | ||
|
||
To create the proper directories as used in the example file: | ||
|
||
```bash | ||
sudo mkdir -p /etc/caddy /etc/ssl/caddy /var/log/caddy /usr/local/bin /var/tmp /srv/www/localhost | ||
sudo touch /etc/caddy/Caddyfile | ||
sudo chown root:wheel -R /usr/local/bin/caddy /Library/LaunchDaemons/ | ||
sudo chown _www:_www -R /etc/caddy /etc/ssl/caddy /var/log/caddy | ||
sudo chmod 0750 /etc/ssl/caddy | ||
``` | ||
|
||
Create a simple web page and Caddyfile | ||
|
||
```bash | ||
sudo bash -c 'echo "Hello, World!" > /srv/www/localhost/index.html' | ||
sudo bash -c 'echo "http://localhost { | ||
root /srv/www/localhost | ||
}" >> /etc/caddy/Caddyfile' | ||
``` | ||
|
||
Start and Stop the Caddy launchd service using the following commands: | ||
|
||
$ launchctl load ~/Library/LaunchAgents/com.caddyserver.web.plist | ||
$ launchctl unload ~/Library/LaunchAgents/com.caddyserver.web.plist | ||
```bash | ||
launchctl load /Library/LaunchDaemons/com.caddyserver.web.plist | ||
launchctl unload /Library/LaunchDaemons/com.caddyserver.web.plist | ||
``` | ||
|
||
To start on every boot use the `-w` flag (to write): | ||
|
||
```bash | ||
launchctl load -w /Library/LaunchAgents/com.caddyserver.web.plist | ||
``` | ||
|
||
More information can be found in this blogpost: [Running Caddy as a service on macOS X server](https://denbeke.be/blog/software/running-caddy-as-a-service-on-macos-os-x-server/) | ||
More information can be found in this blogpost: [Running Caddy as a service on macOS X server](https://denbeke.be/blog/software/running-caddy-as-a-service-on-macos-os-x-server/) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Label</key> | ||
<string>com.caddyserver.web</string> | ||
<key>EnvironmentVariables</key> | ||
<dict> | ||
<key>HOME</key> | ||
<string>/Users/mathias</string> | ||
</dict> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>sh</string> | ||
<string>-c</string> | ||
<string>ulimit -n 8192; cd /Users/mathias/Sites; ./caddy -agree -email [email protected] -conf=/Users/mathias/Sites/Caddyfile</string> | ||
</array> | ||
<key>UserName</key> | ||
<string>www</string> | ||
<key>RunAtLoad</key> | ||
<true/> | ||
<key>KeepAlive</key> | ||
<true/> | ||
<key>WorkingDirectory</key> | ||
<string>/Users/mathias/Sites</string> | ||
<key>StandardOutPath</key> | ||
<string>/Users/mathias/Sites/caddy.log</string> | ||
<key>StandardErrorPath</key> | ||
<string>/Users/mathias/Sites/caddy_error.log</string> | ||
</dict> | ||
</plist> | ||
<dict> | ||
<key>Label</key> | ||
<string>Caddy</string> | ||
<key>ProgramArguments</key> | ||
<array> | ||
<string>/usr/local/bin/caddy</string> | ||
<string>-agree</string> | ||
<string>-conf</string> | ||
<string>/etc/caddy/Caddyfile</string> | ||
<string>-root</string> | ||
<string>/var/tmp</string> | ||
</array> | ||
<key>EnvironmentVariables</key> | ||
<dict> | ||
<key>CADDYPATH</key> | ||
<string>/etc/ssl/caddy</string> | ||
</dict> | ||
|
||
<key>UserName</key> | ||
<string>root</string> | ||
<key>GroupName</key> | ||
<string>wheel</string> | ||
<key>InitGroups</key> | ||
<true/> | ||
|
||
<key>RunAtLoad</key> | ||
<true/> | ||
<key>KeepAlive</key> | ||
<dict> | ||
<key>Crashed</key> | ||
<true/> | ||
</dict> | ||
|
||
<key>SoftResourceLimits</key> | ||
<dict> | ||
<key>NumberOfFiles</key> | ||
<integer>8192</integer> | ||
</dict> | ||
<key>HardResourceLimits</key> | ||
<dict/> | ||
|
||
<key>WorkingDirectory</key> | ||
<string>/etc/ssl/caddy</string> | ||
|
||
<key>StandardErrorPath</key> | ||
<string>/var/log/caddy/error.log</string> | ||
<key>StandardOutPath</key> | ||
<string>/var/log/caddy/info.log</string> | ||
</dict> | ||
</plist> |