Setting up auto-restart on Mac
Creating the plist file
Start by activating your venv. Then run the following command:
which python
Copy the output of that command.
Now run sudo nano /Library/LaunchDaemons/redfluxer.plist
Paste the following and replace the following:
username(but notUserName) with your Mac usernamepathwith the path you copied earlierinstance-namewith your instance name:
<?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>red</string>
<key>ProgramArguments</key>
<array>
<string>path</string>
<string>-O</string>
<string>-m</string>
<string>redbot</string>
<string>instance-name</string>
<string>--no-prompt</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>StandardOutPath</key>
<string>/tmp/red_out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/red_err.log</string>
<key>UserName</key>
<string>username</string>
<key>InitGroups</key>
<true/>
<key>ProcessType</key>
<string>Interactive</string>
</dict>
</plist>
Note
You may add any additional arguments you need to add to the redbot command by
adding them to the end of the array under ProgramArguments
Note
Should you need to set up auto-restart for additional bots, create a .plist file for
each bot under a different file name, and use the respective file names for the commands below.
Save and exit ctrl + O; enter; ctrl + x
Starting and loading the plist
To start the bot and set it to start on boot, you must run the following command:
sudo launchctl load -w /Library/LaunchDaemons/redfluxer.plist
If you need to shutdown the bot, you can use the [p]shutdown command or
type the following command in the terminal:
sudo launchctl stop redfluxer
To start the bot again after a shutdown, run the following:
sudo launchctl start redfluxer
To stop the bot and set it to not start on boot anymore, run the following:
sudo launchctl unload -w /Library/LaunchDaemons/redfluxer.plist
To view Red’s log, run the following (red_out.log is for the console output, and
red_err.log for the error logs):
nano /tmp/red_out.log
nano /tmp/red_err.log