# How to specify alternate configuration in multisite

**URL:** https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441
**Category:** Self-hosting
**Created:** [May 10, 2017, 3:24pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441 "2017-05-10T15:24:32Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 3:24pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/1 "2017-05-10T15:24:32Z")

</div>

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`?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 10, 2017, 4:46pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/2 "2017-05-10T16:46:20Z")

</div>

> [@pfaffman](#):
>
> how do I pass a database name to rake admin:create?

`RAILS_DB=bob rake admin:create`

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 5:34pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/3 "2017-05-10T17:34:52Z")

</div>

> [@sam](#):
>
> RAILS\_DB=bob rake admin:create

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

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 10, 2017, 5:41pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/4 "2017-05-10T17:41:12Z")

</div>

> [@pfaffman](#):
>
> I didn’t name the database ‘bob’, so I’d expect an error here.

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 6:05pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/5 "2017-05-10T18:05:19Z")

</div>

```plaintext
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

```

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [May 10, 2017, 6:23pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/6 "2017-05-10T18:23:09Z")

</div>

You should use `RAILS_DB=discourse_instance2` for [forum.literatecomputing.com](http://forum.literatecomputing.com).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 10, 2017, 6:26pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/7 "2017-05-10T18:26:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 6:47pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/8 "2017-05-10T18:47:08Z")

</div>

> [@pfaffman](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 8:52pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/9 "2017-05-10T20:52:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 10, 2017, 9:04pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/10 "2017-05-10T21:04:41Z")

</div>

> [@pfaffman](#):
>
> Anybody see anything obviously wrong in my snippet above?

“`ooks`” vs “`hooks`”?  
Obviously your `multisite.yml` building should probably be under the `before_bundle_exec` hook.

> [@pfaffman](#):
>
> Sidekiq isn’t running for any of the other hosts.

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

Is your data container separate?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 9:07pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/11 "2017-05-10T21:07:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 9:23pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/12 "2017-05-10T21:23:10Z")

</div>

Well, I got the error again with a clean build. My config file is at [this gist](https://gist.github.com/pfaffman/0dd2aa5848c59c1ffdef3348fa403d28).

Looks like it might be a bug, though I’m a novice at multisite.

I get a bunch of errors like this:

````plaintext
 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
                                           ^
```
````

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 10, 2017, 9:27pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/13 "2017-05-10T21:27:03Z")

</div>

> [@pfaffman](#):
>
> My config file is at this gist.

you have two `after_code:` sections.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 9:46pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/14 "2017-05-10T21:46:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 10, 2017, 9:47pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/15 "2017-05-10T21:47:56Z")

</div>

> [@pfaffman](#):
>
> but I still can’t connect to sidekiq.

Did you see this comment?

> [@DeanMarkTaylor](#):
>
> I’m pretty sure there is only one Sidekiq running for all sites, check the main (first) site

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 9:51pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/16 "2017-05-10T21:51:40Z")

</div>

Oh. Ooops. 😊

Now I see that those jobs have a current\_site\_id set.

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

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 10, 2017, 9:53pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/17 "2017-05-10T21:53:01Z")

</div>

> [@pfaffman](#):
>
> but none are scheduled.

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 10:00pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/18 "2017-05-10T22:00:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 10, 2017, 10:05pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/19 "2017-05-10T22:05:27Z")

</div>

That’s fine but this..

> [@sam](#):
>
> yeah we should probably make it explode instead of choose default for invalid db names

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 10:06pm UTC](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441/20 "2017-05-10T22:06:40Z")

</div>

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

[Next page](https://meta.discourse.org/t/how-to-specify-alternate-configuration-in-multisite/62441.md?page=2)
