How to change the number of unicorns?

Hello,

I would like to know how to set the number of running unicorns. I need it to adjust the RAM consumption and failed to find any specific information about it on this forum and on the net.

I am looking for information such as the location of the correct file, the name of the line to change, if there is some precaution to take, etc.

I suppose that after the changes, it is necessary to restart/rebuild the software. How to do it properly?

Thank you for your time.

1 Like

To edit these settings you can edit the app.yml

cd /var/discourse
nano containers/app.yml

Around the line 48 you should have this:

## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 8

I’m not an expert in this area but you might want to check the lines ~30 to reduce the number:

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "2048MB"

Save the file (CTRL+X then Y usually), then you indeed have to rebuild discourse to use the new settings, using:

./launcher rebuild app

Your forum will be offline around 10 minutes during the process

5 Likes

I think, but I haven’t tested, that the UNICORN_WORKERS is set in an env and not in any config file, so you don’t need to rebuild but can just

 ./launcher destroy app;./launcher start app

I’m pretty sure (but haven’t looked) that changes to db_shared_buffers to require a rebuild (or you could go an edit the corresponding settings file inside the container and then restart it).

2 Likes

My discourse install has been done via Yunohost and it seems that some things are different. I didn’t manage to find the app.yml file.

I am waiting for an answer from the Yunohost team. I’ll keep you in touch.

1 Like

I’m self-hosting my Discourse forum on Yunohost, and I ran into an issue with the SMTP email configuration. After scouring the meta.discourse documentation, I couldn’t find any information on Yunohost’s specific operations or save locations. I uninstalled and reinstalled Discourse, copied the log file, and finally located the configuration file that contained the SMTP information.

If you’re also using Yunohost and need to configure your Discourse SMTP settings, you can find the file you’re going to modify at

/var/www/discourse/config/discourse.conf.

Open that file, configure the SMTP settings, save and exit, and then restart Discourse with the command “systemctl restart discourse”.

root@yuno:~# nano /var/www/discourse/config/discourse.conf
root@yuno:~# systemctl restart discourse

And if it helps anyone else, because also, I couldn’t find information -

To configure Discourse with your Office365 you’ve got to do the following:

  1. Go to your Microsoft 365 admin center
  2. Click on Settings then Domains
  3. Click on Add Domain
  4. Follow the instructions on the screen to add your forum’s URL
  5. Once you’ve completed the above steps and the DNS is verified, you’re now able to create an inbox using that subdomain
  6. Click on Users and then Active users
  7. Click on Add a user
  8. Create the mailbox for your forum (example: noreply@forum.yourlinks.com) mailbox domain must match the hostname from where the forum runs
  9. Click on Licenses & Apps
  10. Assign this mailbox an Exchange Online (Plan 1) license (10,000 messages daily 30msg/min throttle) It is required to have a license attached to the mailbox for the purpose of direct-delivery. At the time of writing, the cost is $4.00USD/mo or $5.10/CAD | Should you require a higher limit or a shorter throttle, there are other plans available
  11. Click on Mail and then Manage email apps
  12. Enable “Authenticated SMTP”
  13. Click Save changes
  14. Go to your Azure portal
  15. Browse to your active directory
  16. Select Properties in the left sidebar, right under User settings
  17. Select Manage security defaults
  18. Set Security defaults to “disabled”
  19. Click save
  20. Go back to Users > Active users
  21. Click on Multi-factor authentication
  22. Disable MFA on the mailbox being used

Now as far as Office365/Microsoft365 is concerned, your newly created mailbox is now ready to direct send on behalf of your Discourse instance.

Settings to use the Office365 mailbox:
modify these lines in /var/www/discourse/config/discourse.conf

# hostname running the forum
hostname = "forum.yourlinks.com"

# backup hostname mainly for cdn use
backup_hostname =

# address of smtp server used to send emails
smtp_address = smtp.office365.com

# port of smtp server used to send emails
smtp_port = 587

# domain passed to smtp server
smtp_domain = forum.yourlinks.com

# username for smtp server
smtp_user_name = noreply@forum.yourlinks.com

# password for smtp server
smtp_password = YourLinksPassWordHere

# smtp authentication mechanism
smtp_authentication = login

# enable TLS encryption for smtp connections
smtp_enable_start_tls = true

# mode for verifying smtp server certificates
# to disable, set to 'none'
smtp_openssl_verify_mode =

# force implicit TLS as per RFC 8314 3.3
smtp_force_tls = false

# load MiniProfiler in production, to be used by developers
load_mini_profiler = false

# hostname running the forum
hostname = "forum.yourlinks.com"