Get bench to listen to a particular port number

Query from my hosting provider - since we need to use a preassigned port that’s generated at random.

I’m assuming the bench command has some sort of configuration option to assign its port, so you can use a proxy port app to get a port assignment and then configure bench to listen on that port.

How do I get bench to ‘listen’ to a pre-defined port number ?

You can set port number in site_config.json
¿Are you running in production mode?

At OpalStack.com it’ll be in production mode.

bench set-nginx-port yoursite.com yourport

(sample: bench set-nginx-port anjanesh.com 20001)

Then

bench setup nginx
sudo service nginx reload

Hope this helps.

No root access even on a VPS because its managed - Frequently Asked Questions - Opalstack Documentation

So I won’t be able to bench set-nginx-port

But I think we’re missing the point here - what we want is to change the port number of frappe’s bundled web server (gunicorn) which we can run on OpalStack as an app on a pre-assigned port number generated by OpalStack which we need to set in manually in frappe’s custom server’s config. OpalStack’s default NGINX will connect to frappe’s server’s port and run it within itself.

This is how we can run Tomcat, NextJS, Go or any other server within the shared resources - but in the user’s home directory and allocated resources.

Normal Frappe installation runs NGINX too … “bench set-nginx-port” actually changes the port in nginx config … pointing to “internal” port.

You can edit this “internal” port in common_site_config.json (located in sites directory)
The key to touch is “webserver_port”: xxxx

Hope this helps.

If you’re executing bench start it picks up commands from Procfile, change the port of bench serve command in Procfile.

in case of supervisor is used, change port in supervisor config.

bench setup supervisor
bench setup procfile

both commands update the config, they pick the port from common_site_config.json

I realize this may not be possible on a managed VPS hosting without sudo access.
Guess I’ll stick to a Ubuntu droplet at DigitalOcean.
I’ll use the EasyScript.