How to specify alternate configuration in multisite

I have a multisite instance & when I try to reset password for an admin user (the only user), I receive the email, but clicking the link just takes me to the home page, not logged in, and no prompt to change the password.

Related: how do I pass a database name to rake admin:create?

RAILS_DB=bob rake admin:create

5 Likes

I think thatā€™s what I thought, but it doesnā€™t seem to be passing the database.

root@support-multi:/var/www/discourse# RAILS_DB=bob rake admin:create
Email:  pfaffman@gmail.com
User with this email already exists! Do you want to reset the password for this email? (Y/n) 

I didnā€™t name the database ā€˜bobā€™, so Iā€™d expect an error here. It seems to be accessing the default database.

yeah we should probably make it explode instead of choose default for invalid db names. What is in multisite.yaml?

2 Likes
ooks:
  after_postgres:
     - exec: sudo -u postgres createdb discourse_forum|| exit 0
     - exec:
          stdin: |
            grant all privileges on database discourse_forum to discourse;

          cmd: sudo -u postgres psql discourse_forum
          raise_on_fail: false

...

     - exec: /bin/bash -c 'sudo -u postgres psql discourse_forum <<< "alter schema public owner to discourse;"'
     - exec: /bin/bash -c 'sudo -u postgres psql discourse_forum <<< "create extension if not exists hstore;"'
     - exec: /bin/bash -c 'sudo -u postgres psql discourse_forum <<< "create extension if not exists pg_trgm;"'
...
         discourse_instance2:
           adapter: postgresql
           database: discourse_forum
           pool: 25
           timeout: 5000
           db_id: 2
           host_names:
             - forum.literatecomputing.com


You should use RAILS_DB=discourse_instance2 for forum.literatecomputing.com.

5 Likes

We should blow up here for sure rather than going default when a completely different name is givenā€¦ that is super nutty.

4 Likes

While setting the password via the console has solved my problem, I still wonder whether this is a bug that I canā€™t set an admin password via email.

edit: I figured it out. The sign-up email was being sent with http. Caddy is redirecting to https, but dropping the rest of the URL.

Anybody see anything obviously wrong in my snippet above? Sidekiq isnā€™t running for any of the other hosts.

ā€œooksā€ vs ā€œhooksā€?
Obviously your multisite.yml building should probably be under the before_bundle_exec hook.

Iā€™m pretty sure there is only one Sidekiq running for all sites, check the main (first) site

Is your data container separate?

1 Like

ooks was careless pasting.

Data is in the same container (though I would really like to move it to a separate container).

Edit: my current hypothesis is that at some point I had screwed up the db_id numbers for a couple sub-hosts. Iā€™m rebuilding the container with a different name now and donā€™t see that error. . .

Well, I got the error again with a clean build. My config file is at this gist.

Looks like it might be a bug, though Iā€™m a novice at multisite.

I get a bunch of errors like this:

 Failed to initialize site discourse_instance2
2017-05-10 21:17:15 UTC [20343-1] discourse@discourse_trena ERROR:  relation "site_settings" does not exist at character 36
2017-05-10 21:17:15 UTC [20343-2] discourse@discourse_trena STATEMENT:  SELECT name, data_type, value FROM site_settings
URGENT: ERROR:  relation "site_settings" does not exist
LINE 1: SELECT name, data_type, value FROM site_settings
                                           ^
```

you have two after_code: sections.

3 Likes

Well, that seems to have fixed those errors, but I still canā€™t connect to sidekiq.

Did you see this comment?

2 Likes

Oh. Ooops. :blush:

Now I see that those jobs have a current_site_id set.

Edit: 0 have been processed. There are 2502 scheduled.

Scheduled are ones that are ā€œscheduledā€ to occur at a specific time.

Geez. I have too many tabs open. I was looking at a development instance.

I now understand that there is one sidekiq for all sites. I now see that itā€™s processed all of its jobs.

Perhaps I should stop using computers today.

Thanks for your help, @DeanMarkTaylor.

If someone deletes or unlists this thread, thatā€™d be OK by me. :slight_smile:

4 Likes

Thatā€™s fine but thisā€¦

needs to be fixed first cc @sam ā€¦ thatā€™s real bad behavior

2 Likes

I guess Iā€™ll have to live with my carelessness and dirty laundry for all to see, then. :slight_smile: