Skip to content

Ports & Proxy

Adam Cooke edited this page Mar 20, 2017 · 4 revisions

Procodile can handle allocation of ports to your process. When you use this, Procodile will simply set a PORT environment variable for a process when it is started. You can use the --ports option when starting processes to choose how ports should be by allocated. By default, no ports will be allocated (unless the proxy is being used - see below).

To allocate ports to processes, just pass the process names to the --ports variable when running procodile start. For example: --ports=web,websocket.

Proxy

Procodile has a built-in development-only proxy which allows you to route traffic to the instances of your processes (much like you'll probably do in production). This proxy should only be used in development and is not designed to handle production traffic - you should use something like nginx or HAProxy.

When you enable the proxy for a process, Procodile will listen on the TCP port you specified and pass data from this port to the ports which your process will open.

Procodile will provide your process with a port to listen on in the PORT environment variable.

Why do this?

Many applications are usually all configured to listen on the same port which can be irritating in development if you have to stop one to work on another. Using the proxy, you can choose the ports you want to use (in a Procfile.local file) and let the system choose which ports to actually assign to the running processes.

How do I set it up?

To enable the proxy you need to start the supervisor with the --proxy (or -x for short) option and you need to add a proxy_port in your configuration file. When you've done this, stop everything and start it again - you should see that it's listening on your new port.

$ procodile stop --stop-supervisor
$ procodile start --proxy

You'll be able to use the procodile status command to see further information.