Mac autostart docs #4082

Merged
palmtree5 merged 15 commits from V3/docs/mac_autostart into V3/develop 2021-04-16 02:58:22 +02:00
palmtree5 commented 2020-07-18 06:37:45 +02:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Supersedes #2726

This one definitely needs testing by someone with a Mac as I do not have a Mac

### Type - [ ] Bugfix - [ ] Enhancement - [x] New feature ### Description of the changes Supersedes #2726 This one definitely needs testing by someone with a Mac as I do not have a Mac
tekulvw (Migrated from github.com) reviewed 2020-07-18 06:37:45 +02:00
Ryan5453 commented 2021-02-07 05:05:03 +01:00 (Migrated from github.com)

I tested this a few days ago and wanted to note that I couldn't get it to work. Maybe I was just doing it wrong but even at that point I think the docs need to be tweaked a little bit because they're a little confusing and I wouldn't expect the end user to be able to figure this out.

I also wanted to point out that the PM2 guide for Linux does work completely on Mac, with no changes needed. That does require node & npm to be installed though, so I still think these docs are a good idea but still need some work.

I tested this a few days ago and wanted to note that I couldn't get it to work. Maybe I was just doing it wrong but even at that point I think the docs need to be tweaked a little bit because they're a little confusing and I wouldn't expect the end user to be able to figure this out. I also wanted to point out that the [PM2 guide for Linux](https://docs.discord.red/en/stable/autostart_pm2.html) does work completely on Mac, with no changes needed. That does require node & npm to be installed though, so I still think these docs are a good idea but still need some work.
aikaterna commented 2021-03-01 20:48:24 +01:00 (Migrated from github.com)

Hi there, I finally was successful in using a plist to start Red on a Catalina machine (10.15.7). I ran into plenty of fun while trying to diagnose this and the other previous PR for Mac autostarting as plist file errors are not very easy to debug.

  • Please include instructions on how to save and exit vi. i.e. using :x
  • I was unable to launch this plist having the UserName be the same as GroupName as the username did not exist as a group name. If the GroupName key is removed it will be set to the default group of the user which is much more ideal than us trying to guess the group the user belongs to.
  • Maybe consider adding error logs, the path is just a suggestion. If we use any path that the UserName cannot access, the plist file will fail silently/show error 78.
        <key>StandardOutPath</key>
        <string>/tmp/red_out.log</string>
        <key>StandardErrorPath</key>
        <string>/tmp/red_err.log</string>
  • Be more explicit about what all to replace in the plist file when creating, like:

Replace:

/path/to/redbot with your redbot executable path
instance-name with your instance name
username with your Mac user name

Hi there, I finally was successful in using a plist to start Red on a Catalina machine (10.15.7). I ran into plenty of fun while trying to diagnose this and the other previous PR for Mac autostarting as plist file errors are not very easy to debug. * Please include instructions on how to save and exit vi. i.e. using `:x` * I was unable to launch this plist having the `UserName` be the same as `GroupName` as the username did not exist as a group name. If the `GroupName` key is removed it will be set to the default group of the user which is much more ideal than us trying to guess the group the user belongs to. * Maybe consider adding error logs, the path is just a suggestion. If we use any path that the `UserName` cannot access, the plist file will fail silently/show error 78. ``` <key>StandardOutPath</key> <string>/tmp/red_out.log</string> <key>StandardErrorPath</key> <string>/tmp/red_err.log</string> ``` * Be more explicit about what all to replace in the plist file when creating, like: Replace: `/path/to/redbot` with your redbot executable path `instance-name` with your instance name `username` with your Mac user name
palmtree5 commented 2021-03-02 06:07:06 +01:00 (Migrated from github.com)

Hi there, I finally was successful in using a plist to start Red on a Catalina machine (10.15.7). I ran into plenty of fun while trying to diagnose this and the other previous PR for Mac autostarting as plist file errors are not very easy to debug.

  • Please include instructions on how to save and exit vi. i.e. using :x

Honestly don't know that I'm a fan of having the user edit the plist file with vi tbh. It tends to be a little complicated for anyone unfamiliar with it. What happens if we do EDITOR=/Applications/TextEdit.app/Contents/MacOS/TextEdit sudo -e /Library/LaunchDaemons/red.plist? I'm thinking if we can have the user edit with a GUI app that they may be a little more familiar with, it may simplify the editing part.

  • I was unable to launch this plist having the UserName be the same as GroupName as the username did not exist as a group name. If the GroupName key is removed it will be set to the default group of the user which is much more ideal than us trying to guess the group the user belongs to.

I'll get this one fixed

  • Maybe consider adding error logs, the path is just a suggestion. If we use any path that the UserName cannot access, the plist file will fail silently/show error 78.
        <key>StandardOutPath</key>
        <string>/tmp/red_out.log</string>
        <key>StandardErrorPath</key>
        <string>/tmp/red_err.log</string>

Good call, it'll help with support to have the logs

  • Be more explicit about what all to replace in the plist file when creating, like:

Replace:

/path/to/redbot with your redbot executable path
instance-name with your instance name
username with your Mac user name

Fair point

> Hi there, I finally was successful in using a plist to start Red on a Catalina machine (10.15.7). I ran into plenty of fun while trying to diagnose this and the other previous PR for Mac autostarting as plist file errors are not very easy to debug. > > * Please include instructions on how to save and exit vi. i.e. using `:x` Honestly don't know that I'm a fan of having the user edit the plist file with `vi` tbh. It tends to be a little complicated for anyone unfamiliar with it. What happens if we do `EDITOR=/Applications/TextEdit.app/Contents/MacOS/TextEdit sudo -e /Library/LaunchDaemons/red.plist`? I'm thinking if we can have the user edit with a GUI app that they may be a little more familiar with, it may simplify the editing part. > * I was unable to launch this plist having the `UserName` be the same as `GroupName` as the username did not exist as a group name. If the `GroupName` key is removed it will be set to the default group of the user which is much more ideal than us trying to guess the group the user belongs to. I'll get this one fixed > * Maybe consider adding error logs, the path is just a suggestion. If we use any path that the `UserName` cannot access, the plist file will fail silently/show error 78. > > ``` > <key>StandardOutPath</key> > <string>/tmp/red_out.log</string> > <key>StandardErrorPath</key> > <string>/tmp/red_err.log</string> > ``` > Good call, it'll help with support to have the logs > * Be more explicit about what all to replace in the plist file when creating, like: > > Replace: > > `/path/to/redbot` with your redbot executable path > `instance-name` with your instance name > `username` with your Mac user name Fair point
aikaterna commented 2021-03-02 21:37:29 +01:00 (Migrated from github.com)

I had some halfway success by using these instructions:

user@iMac / % export EDITOR=/System/Applications/TextEdit.app/Contents/MacOS/TextEdit
user@iMac / % export VISUAL="$EDITOR"                                                
user@iMac / % sudo -e /Library/LaunchDaemons/red.plist  

This does attempt to open the file in TextEdit, and launches the program, but then it said
Screen Shot 2021-03-02 at 12 34 34 PM

After hitting OK and closing the TextEdit process, the terminal window where the original commands were run is "hung" in the idea that it requires a ctrl-c to get back to the command prompt.

I had some halfway success by using these instructions: ``` user@iMac / % export EDITOR=/System/Applications/TextEdit.app/Contents/MacOS/TextEdit user@iMac / % export VISUAL="$EDITOR" user@iMac / % sudo -e /Library/LaunchDaemons/red.plist ``` This does attempt to open the file in TextEdit, and launches the program, but then it said <img width="416" alt="Screen Shot 2021-03-02 at 12 34 34 PM" src="https://user-images.githubusercontent.com/20862007/109711417-b723a280-7b53-11eb-886a-d8fcf975d0d5.png"> After hitting OK and closing the TextEdit process, the terminal window where the original commands were run is "hung" in the idea that it requires a ctrl-c to get back to the command prompt.
Jackenmen commented 2021-03-03 00:12:23 +01:00 (Migrated from github.com)

This guide should be running Red with python -O -m redbot rather than redbot executable directly - same as the systemd guide for Linux.

As for the sudo -e, I think Mac has nano too (which we should have been doing in systemd guide for long time tbh), so we could just use that, assuming it actually works on Mac ofc.

This guide should be running Red with `python -O -m redbot` rather than `redbot` executable directly - same as the systemd guide for Linux. As for the `sudo -e`, I think Mac has `nano` too (which we should have been doing in systemd guide for long time tbh), so we could just use that, assuming it actually works on Mac ofc.
aikaterna commented 2021-03-03 00:25:34 +01:00 (Migrated from github.com)

sudo nano works fine on Mac for this situation instead of sudo -e. I also set python to be the bot's venv's python as Jack suggested with <string>/Users/mac_username/venv_name/bin/python -O -m /Users/mac_username/venv_name/bin/redbot</string> and that worked out ok as well.

`sudo nano` works fine on Mac for this situation instead of `sudo -e`. I also set `python` to be the bot's venv's python as Jack suggested with `<string>/Users/mac_username/venv_name/bin/python -O -m /Users/mac_username/venv_name/bin/redbot</string>` and that worked out ok as well.
Ryan5453 commented 2021-03-03 00:46:18 +01:00 (Migrated from github.com)

idk if this is worthy to add, but while I was testing it I changed
<string>--no-prompt</string>
to
<string>--no-prompt --team-members-are-owners</string>
assuming I could add additional flags, but that did not work (the bot didn't start) and I needed to change it to
<string>--no-prompt</string>
<string>--team-members-are-owners</string>

idk if this is worthy to add, but while I was testing it I changed `<string>--no-prompt</string>` to `<string>--no-prompt --team-members-are-owners</string>` assuming I could add additional flags, but that did not work (the bot didn't start) and I needed to change it to `<string>--no-prompt</string>` `<string>--team-members-are-owners</string>`
Boxck commented 2021-03-03 07:09:48 +01:00 (Migrated from github.com)

Ja takk
tir. 2. mar. 2021, 21:37 skrev aikaterna notifications@github.com:

I had some halfway success by using these instructions:

user@iMac / % export EDITOR=/System/Applications/TextEdit.app/Contents/MacOS/TextEdit
user@iMac / % export VISUAL="$EDITOR"
user@iMac / % sudo -e /Library/LaunchDaemons/red.plist

This does attempt to open the file in TextEdit, and launches the program,
but then it said
[image: Screen Shot 2021-03-02 at 12 34 34 PM]
https://user-images.githubusercontent.com/20862007/109711417-b723a280-7b53-11eb-886a-d8fcf975d0d5.png

After hitting OK and closing the TextEdit process, the terminal window
where the original commands were run is "hung" in the idea that it requires
a ctrl-c to get back to the command prompt.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Cog-Creators/Red-DiscordBot/pull/4082#issuecomment-789198979,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ARVKJTUOWDZ53KOXAZPUMJLTBVEB5ANCNFSM4O7MBCRA
.

Ja takk tir. 2. mar. 2021, 21:37 skrev aikaterna <notifications@github.com>: > I had some halfway success by using these instructions: > > user@iMac / % export EDITOR=/System/Applications/TextEdit.app/Contents/MacOS/TextEdit > user@iMac / % export VISUAL="$EDITOR" > user@iMac / % sudo -e /Library/LaunchDaemons/red.plist > > This does attempt to open the file in TextEdit, and launches the program, > but then it said > [image: Screen Shot 2021-03-02 at 12 34 34 PM] > <https://user-images.githubusercontent.com/20862007/109711417-b723a280-7b53-11eb-886a-d8fcf975d0d5.png> > > After hitting OK and closing the TextEdit process, the terminal window > where the original commands were run is "hung" in the idea that it requires > a ctrl-c to get back to the command prompt. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/Cog-Creators/Red-DiscordBot/pull/4082#issuecomment-789198979>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ARVKJTUOWDZ53KOXAZPUMJLTBVEB5ANCNFSM4O7MBCRA> > . >
palmtree5 commented 2021-03-03 08:55:45 +01:00 (Migrated from github.com)

sudo nano works fine on Mac for this situation instead of sudo -e. I also set python to be the bot's venv's python as Jack suggested with <string>/Users/mac_username/venv_name/bin/python -O -m /Users/mac_username/venv_name/bin/redbot</string> and that worked out ok as well.

Got it, will switch it to sudo nano as nano is way easier to work with than vi if the user is unfamiliar

idk if this is worthy to add, but while I was testing it I changed
<string>--no-prompt</string>
to
<string>--no-prompt --team-members-are-owners</string>
assuming I could add additional flags, but that did not work (the bot didn't start) and I needed to change it to
<string>--no-prompt</string>
<string>--team-members-are-owners</string>

I'll make sure there's a note in about this.

> `sudo nano` works fine on Mac for this situation instead of `sudo -e`. I also set `python` to be the bot's venv's python as Jack suggested with `<string>/Users/mac_username/venv_name/bin/python -O -m /Users/mac_username/venv_name/bin/redbot</string>` and that worked out ok as well. Got it, will switch it to `sudo nano` as `nano` is way easier to work with than `vi` if the user is unfamiliar > idk if this is worthy to add, but while I was testing it I changed > `<string>--no-prompt</string>` > to > `<string>--no-prompt --team-members-are-owners</string>` > assuming I could add additional flags, but that did not work (the bot didn't start) and I needed to change it to > `<string>--no-prompt</string>` > `<string>--team-members-are-owners</string>` I'll make sure there's a note in about this.
palmtree5 commented 2021-03-06 08:48:16 +01:00 (Migrated from github.com)

Ok, all requested changes have been made. Would someone just confirm that running [p]restart for the bot works? Not sure anyone's tested that specifically. Also may want to confirm that which python with the venv activated does indeed get the venv's python and not something else

Ok, all requested changes have been made. Would someone just confirm that running `[p]restart` for the bot works? Not sure anyone's tested that specifically. Also may want to confirm that `which python` with the venv activated does indeed get the venv's python and not something else
Ryan5453 commented 2021-03-06 17:51:56 +01:00 (Migrated from github.com)

I can confirm that [p]restart does work, and which python returned /Users/<my_user>/redenv/bin/python for me (which worked)

I can confirm that `[p]restart` does work, and `which python` returned `/Users/<my_user>/redenv/bin/python` for me (which worked)
Ryan5453 commented 2021-03-06 17:55:41 +01:00 (Migrated from github.com)

One thing that might be worthy to add is how to view the logs, maybe nano /tmp/red_out.log?

One thing that might be worthy to add is how to view the logs, maybe `nano /tmp/red_out.log`?
palmtree5 commented 2021-03-06 19:27:36 +01:00 (Migrated from github.com)

Ooh, good suggestion! Will get that added at some point

On Sat, Mar 6, 2021, 07:55 aleclol notifications@github.com wrote:

One thing that might be worthy to add is how to view the logs, maybe nano
/tmp/red_out.log?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Cog-Creators/Red-DiscordBot/pull/4082#issuecomment-791988727,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA3JLJ4BQZWIG47CL4R63D3TCJNBTANCNFSM4O7MBCRA
.

Ooh, good suggestion! Will get that added at some point On Sat, Mar 6, 2021, 07:55 aleclol <notifications@github.com> wrote: > One thing that might be worthy to add is how to view the logs, maybe nano > /tmp/red_out.log? > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > <https://github.com/Cog-Creators/Red-DiscordBot/pull/4082#issuecomment-791988727>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AA3JLJ4BQZWIG47CL4R63D3TCJNBTANCNFSM4O7MBCRA> > . >
palmtree5 commented 2021-03-07 06:57:23 +01:00 (Migrated from github.com)

Added a note about the logging

Added a note about the logging
aikaterna commented 2021-03-11 18:53:04 +01:00 (Migrated from github.com)

One thing I thought of while testing this again was about the eventual size of the log files because information would be appended to the end of each log in /tmp every time the bot is restarted. I found some information that was rather old (10.6.x) that claims that /tmp is emptied every 3 days but I'm not finding much for Catalina regarding this. This is the only concern I have left before approving this item and am willing to approve it anyway, but we may get people with very large log files if there is no automatic cleaning of /tmp in Catalina.

One thing I thought of while testing this again was about the eventual size of the log files because information would be appended to the end of each log in /tmp every time the bot is restarted. I found some information that was rather old (10.6.x) that claims that /tmp is emptied every 3 days but I'm not finding much for Catalina regarding this. This is the only concern I have left before approving this item and am willing to approve it anyway, but we may get people with very large log files if there is no automatic cleaning of /tmp in Catalina.
aikaterna commented 2021-04-16 02:47:19 +02:00 (Migrated from github.com)

Thanks to a link Palm provided I was able to find some info on, and confirm, that Catalina (10.15.x) should delete those files every 3 days or so. I would expect Big Sur does the same.

Thanks to a link Palm provided I was able to find some info on, and confirm, that Catalina (10.15.x) should delete those files every 3 days or so. I would expect Big Sur does the same.
aikaterna (Migrated from github.com) approved these changes 2021-04-16 02:47:27 +02:00
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!4082
No description provided.