Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rails console docs #170

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/how-to/access--the-rails-console.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# How to access the Rails console

Ideally, the discourse charm should be handled by interacting with Juju, and everything that can be done with the console should
be doable with juju actions. In case there is something that needs to be done with the console anyway, the console can be accessed.

### Prerequisites

Have a Discourse deployment active.

### Access the console

First of all, switch into the juju Discourse model if necessary:
```
juju switch discourse-model
```
Then ssh into the Discourse unit:
```
juju ssh --container discourse discourse-k8s/leader bash
```
Now populate the required environment variables, this requires charm revision 70 or greater:
```
sudo -u _daemon_ xargs -0 -L1 -a "/proc/$(ps aux | awk '/[u]nicorn master/ {print $2;exit}')/environ" | awk '{FS="=";print "export " $1 "=\"" $2 "\""}' > /root/envi && . /root/envi && rm /root/envi
```
gtrkiller marked this conversation as resolved.
Show resolved Hide resolved
Now change to the appropriate directory and execute the command to access the console:
```
cd /srv/discourse/app
RAILS_ENV=production bin/bundle exec rails console
```
If the output of the last command contains something similar to this:
```
Loading production environment (Rails 7.0.5.1)
irb(main):001:0>
```
Congratulations, you have accessed the rails console.
Loading