Any way to play with nginx conf values without rebuilding?

AI-generated summary

In a discussion about modifying nginx configuration values without rebuilding Discourse, helmi seeks a way to tweak worker_connections and worker_processes dynamically. pfaffman suggests entering the container via ./launcher enter app, installing an editor (like vim or nano) with apt, editing nginx.conf, and restarting nginx with sv restart nginx. helmi initially reports no apt sources available, making installs fail — even vi, vim, or nano cannot be installed. Arkshine and Jagster advise running apt update first, which Jagster confirms works on Ubuntu. helmi insists there are no sources, but pfaffman confirms the same commands work on a fresh install. After some confusion, helmi reports it now works — though unsure why — and Arkshine reassures them it happens. The consensus: editing nginx.conf directly in the container is viable for testing, though not recommended for production since changes are lost on rebuild. Rebuilding typically causes under a minute of downtime.

I’m already using higher values for worker_connections and worker_processes on nginx through replace rules in app.yml

Though I would play around to find the best values a bit ideally without rebuilding discourse every time. Is there a way to change nginx.conf in the container and restarting nginx process without rebuilding discourse all over?

Yes, you can go into the contain (e.g., ./launcher enter app) use apt to install an editor, edit the NGINX files and sv restart nginx (reload might work?).

That’s a way I thought about and tried until i saw that there isn’t even a single source for apt. Adding one myself kind of sounds a bit flaky for system I don’t know and runs in production. Having at least vi there would really help for some simple tasks wink, wink :wink:

I have never paid attention to the apt sources, but I have several templates that do an apt-get update; apt-get install to install stuff in the container (my dashboard.literatecomputing.com needs python and ansible, for example). It works, or did as recently as last Friday. Similarly, the template I use for doing migrations add vim and some other stuff.

I don’t recommend hand-editing stuff for production, as the changes will obviously go away at the next rebuild, but if what you want to do is just test values to find the ones that work, this is likely a good-enought solution (as it avoids a bunch of rebuilds).

Also 2-container setup typicall has <1 minute of downtime when you do a rebuild and start the new container.

I wouldn’t pay attention to apt sources as well but without sources there’s no install, otherwise I really wouldn’t care.

root@forum-app:/var/www/discourse# apt install vi
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package vi
root@forum-app:/var/www/discourse# apt list sources
Listing... Done
root@forum-app:/var/www/discourse#

it’s the same for apt-get and vim or nano - just to make sure :wink:

Did you run apt update before using apt install? The first time, you need to refresh the source list.

Ubuntu something and after apt update && apt dist-upgrade (where I answered no, because it wanted update pqsl and I paniced) apt install nano succeeded ok.

Well there are no sources - apt updates does nothing without sources :wink:

This is a standard install?

I just ran

apt update
apt installl -y vim

on a site that I built today and installled vim.

Within the discourse container? Very standard install.

I can’t explain then why the code I pasted above won’t work for you. I did it today and have been doing it for years.

For me on Ubuntu after /launcher enter app I can give apt update && apt install nano -y [1] succesfully. So if apt doesn’t work I would say either system itself or docker is broken :thinking:


  1. vim is more S/M type editor… ↩︎

Interestingly it now works for me as well - doubting my life to be honest - not sure what it was but it now works. sigh

No worry, it happens! I’m glad it works now. :+1: