How to specify alternate configuration in multisite

(Jay Pfaffman) #1

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?

(Sam Saffron) #2

RAILS_DB=bob rake admin:create

(Jay Pfaffman) #3

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
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.

(Sam Saffron) #4

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

(Jay Pfaffman) #5
     - 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;"'
           adapter: postgresql
           database: discourse_forum
           pool: 25
           timeout: 5000
           db_id: 2

Trouble with Sidekiq on multisite
(Neil Lalonde) #6

You should use RAILS_DB=discourse_instance2 for

(Jeff Atwood) #7

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

(Jay Pfaffman) #8

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.

(Jay Pfaffman) #9

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

(Dean Taylor) #10

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?

(Jay Pfaffman) #11

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. . .

(Jay Pfaffman) #12

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

(Dean Taylor) #13

you have two after_code: sections.

(Jay Pfaffman) #14

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

(Dean Taylor) #15

Did you see this comment?

(Jay Pfaffman) #16

Oh. Ooops. :blush:

Now I see that those jobs have a current_site_id set.

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

(Dean Taylor) #17

Scheduled are ones that are “scheduled” to occur at a specific time.

(Jay Pfaffman) #18

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:

(Jeff Atwood) #19

That’s fine but this…

needs to be fixed first cc @sam … that’s real bad behavior

(Jay Pfaffman) #20

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