Skip to content

Commit

Permalink
Add launchctl service and ditch Tmux (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
remi committed May 4, 2023
1 parent 7544f28 commit 45ffa3a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
15 changes: 8 additions & 7 deletions host/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ Still from your local machine, copy a few files from this repository. The `domai
```
$ scp domain.crt admin@<HOST_IP>
$ scp launch.sh admin@<HOST_IP>:vm
$ scp com.mirego.ekiden.plist admin@<HOST_IP>:vm
$ scp .env admin@<HOST_IP>:vm
$ scp id_rsa admin@<HOST_IP>:.ssh
$ scp id_rsa.pub admin@<HOST_IP>:.ssh
```

### Install Tools

On the remote machine, install [Homebrew](https://brew.sh), `tmux`, `wget` and [tart](https://github.com/cirruslabs/tart/)
On the remote machine, install [Homebrew](https://brew.sh), `wget` and [tart](https://github.com/cirruslabs/tart/)

```
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew install tmux wget cirruslabs/cli/tart
$ brew install wget cirruslabs/cli/tart
```

### Install Certificate
Expand All @@ -67,12 +68,12 @@ $ security add-trusted-cert -d -k ~/Library/Keychains/login.keychain domain.crt

### Start the Runner

Start tmux and launch a new runner!
Install the service and launch it.

```
$ tmux
$ cd vm
$ ./launch.sh
$ sudo chown root:wheel launch.sh
$ sudo cp com.mirego.ekiden.plist /Library/LaunchDaemons
$ sudo launchctl load -w /Library/LaunchDaemons/com.mirego.ekiden.plist
```

You can now detach from tmux with (press `^B`, release and then `d`)
You can now logout from the server.
26 changes: 26 additions & 0 deletions host/com.mirego.ekiden.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.mirego.ekiden</string>
<key>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>/Users/admin/vm/launch.sh</string>
</array>
<key>UserName</key>
<string>admin</string>
<key>WorkingDirectory</key>
<string>/Users/admin/vm</string>
<key>StandardErrorPath</key>
<string>/Users/admin/vm/stderr</string>
<key>StandardOutPath</key>
<string>/Users/admin/vm/stdout</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
3 changes: 3 additions & 0 deletions host/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ if [ -f .env ]; then
export $(xargs <.env)
fi

# Configure Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"

# Show a shutdown message when closing the script
trap "log_output \"[HOST] 🚦 Stopping runner script\"; exit 1" SIGINT

Expand Down

0 comments on commit 45ffa3a

Please sign in to comment.