process-compose icon indicating copy to clipboard operation
process-compose copied to clipboard

A column to display the `port` a process is listening on

Open shivaraj-bh opened this issue 1 year ago • 16 comments

Feature Request

Use Case:

It will be inconvenient to scroll up the logs of the process to usually find the port it is listening on, a port column will be nice to have.

Proposed Change:

Who Benefits From The Change(s)?

Alternative Approaches

shivaraj-bh avatar Sep 09 '24 15:09 shivaraj-bh

Hi @shivaraj-bh,

Just to make sure, are you aware that this information already exists in the general process info F3? Do you think it deserves a dedicated column?

F1bonacc1 avatar Sep 09 '24 20:09 F1bonacc1

I can’t see that in F3, is there any configuration that needs to be set? in this case, the port used by postgres. image

shivaraj-bh avatar Sep 10 '24 08:09 shivaraj-bh

Do you think it deserves a dedicated column?

I don’t mind if its available in F3 for now, regarding whether this deserves a column, you can take call once there are enough thumbs ups on this issue.

shivaraj-bh avatar Sep 10 '24 08:09 shivaraj-bh

Are you running postgres in a script? The port should be visible like in the screenshot below: image

F1bonacc1 avatar Sep 10 '24 21:09 F1bonacc1

Ah yes, it is in a script. Is there any workaround for such a case, i.e can we set this TCP port manually?

shivaraj-bh avatar Sep 11 '24 05:09 shivaraj-bh

Ah yes, it is in a script. Is there any workaround for such a case, i.e can we set this TCP port manually?

Use exec postgres instead of just postgres at the end of the script so the postgres process replaces the bash script.

thenonameguy avatar Sep 11 '24 07:09 thenonameguy

Ah yes, it is in a script. Is there any workaround for such a case, i.e can we set this TCP port manually?

Use exec postgres instead of just postgres at the end of the script so the postgres process replaces the bash script.

Thanks for the suggestion. This didn’t work though. Here’s my script:

set -o errexit
set -o nounset
set -o pipefail

export PATH="/nix/store/w11g7nvm4h1ph7kjq6c4cxna3yppsn2v-postgresql-16.4/bin:/nix/store/vb8mdklw65p9wikp97ybmnyay0xzipx3-coreutils-9.5/bin:$PATH"

PGDATA=$(readlink -f "./data/pg1")
export PGDATA
exec postgres

And the corresponding screenshot with F3 on the process: image

shivaraj-bh avatar Sep 11 '24 08:09 shivaraj-bh

Ah yes, it is in a script. Is there any workaround for such a case, i.e can we set this TCP port manually?

Use exec postgres instead of just postgres at the end of the script so the postgres process replaces the bash script.

Thanks for the suggestion. This didn’t work though. Here’s my script:

set -o errexit
set -o nounset
set -o pipefail

export PATH="/nix/store/w11g7nvm4h1ph7kjq6c4cxna3yppsn2v-postgresql-16.4/bin:/nix/store/vb8mdklw65p9wikp97ybmnyay0xzipx3-coreutils-9.5/bin:$PATH"

PGDATA=$(readlink -f "./data/pg1")
export PGDATA
exec postgres

And the corresponding screenshot with F3 on the process: image

Thanks for trying it, sorry it didn't work. Can you please post a screenshot of process-compose htop screenshot with tree mode enabled (F5)? The immediate child process should be postgresql, nothing in between.

thenonameguy avatar Sep 11 '24 08:09 thenonameguy

image

There is a top-level script that starts process-compose and directly under it is the postgres process. This is the top-level script:

#!/nix/store/vpvy79k1qq02p1vyqjk6nb89gwhxqvyb-bash-5.2p32/bin/bash
set -o errexit
set -o nounset
set -o pipefail

export PATH="/nix/store/4sxr0bayv0rv5xpmm7ma8p8ks3ls0lml-process-compose-1.24.2/bin:$PATH"

export PC_CONFIG_FILES=/nix/store/l7dkx7fk9i6i94m32bi800wlakika46z-process-compose-postgres.json



set -x; process-compose --no-server \
 "$@"; set +x

shivaraj-bh avatar Sep 11 '24 09:09 shivaraj-bh

Hey @shivaraj-bh,

Will you be able to provide an output of:

ss -tulpn | grep postgres

F1bonacc1 avatar Oct 02 '24 09:10 F1bonacc1

❯ ss -tulpn | grep postgres
tcp   LISTEN 0      200                                    127.0.0.1:5433       0.0.0.0:*    users:(("postgres",pid=2807031,fd=8))
tcp   LISTEN 0      200                                    127.0.0.1:5432       0.0.0.0:*    users:(("postgres",pid=2806984,fd=8))

shivaraj-bh avatar Oct 02 '24 10:10 shivaraj-bh

tcp   LISTEN 0      200                                    127.0.0.1:5433       0.0.0.0:*    users:(("postgres",pid=2807031,fd=8))
tcp   LISTEN 0      200                                    127.0.0.1:5432       0.0.0.0:*    users:(("postgres",pid=2806984,fd=8))
                                                                                                                    ^^^^^^^

Is this PID 2806984 equal to the one shown by PC?

F1bonacc1 avatar Oct 02 '24 11:10 F1bonacc1

image

Yes, see pg1 and pg2. Also included pg1’s process info

shivaraj-bh avatar Oct 02 '24 11:10 shivaraj-bh

Last question. Can you please:

> cd /proc/net
> grep 1538 *

and share the output (including the file name).

1538 = HEX(5432)

F1bonacc1 avatar Oct 02 '24 11:10 F1bonacc1

tcp:   4: 0100007F:1538 00000000:0000 0A 00000000:00000000 00:00000000 00000000  1000        0 14071023 1 ffff88830e853600 100 0 0 10 0     
tcp:   5: 0100007F:DA7A 0100007F:1538 06 00000000:00000000 03:00000032 00000000     0        0 0 3 ffff888128775ed0                         
tcp:   7: 0100007F:AADC 0100007F:1538 06 00000000:00000000 03:0000041A 00000000     0        0 0 3 ffff8882a8bac660                         
tcp:  10: 0100007F:D18A 0100007F:1538 06 00000000:00000000 03:000013BA 00000000     0        0 0 3 ffff888b28b5eee0                         
tcp:  16: 0100007F:CC56 0100007F:1538 06 00000000:00000000 03:00000802 00000000     0        0 0 3 ffff8881acd96660                         
tcp:  17: 0100007F:87C0 0100007F:1538 06 00000000:00000000 03:00000BEA 00000000     0        0 0 3 ffff88835e03eaa0                         
tcp:  19: 0100007F:ED3A 0100007F:1538 06 00000000:00000000 03:00000FD2 00000000     0        0 0 3 ffff88812108ccc0 

shivaraj-bh avatar Oct 02 '24 11:10 shivaraj-bh

Hi @shivaraj-bh, Can you please confirm that the issue still exists in v1.40?

F1bonacc1 avatar Nov 09 '24 23:11 F1bonacc1