joe-at-startupmedia / pmon3

Golang Production Process Manager
10 stars 0 forks source link

attempting to create a new process with the same binary but different name argument errors #6

Closed joe-at-startupmedia closed 10 months ago

joe-at-startupmedia commented 10 months ago
╭─╥─────╥───────────────╥──────────╥──────────╥───────────────╥─────╥──────────╥────────────────────╮
│✓║ id  ║Name           ║PID       ║status    ║user           ║CPU  ║mem       ║date                │
├─╫─────╫───────────────╫──────────╫──────────╫───────────────╫─────╫──────────╫────────────────────┤
│ ║  2  ║happac         ║402219    ║running   ║terraform      ║0%   ║5.8 MB    ║2023-12-31 07:21:04 │
├─╨─────╨───────────────╨──────────╨──────────╨───────────────╨─────╨──────────╨────────────────────┤
│Pg. 1/1 - Currently looking at ID: 2                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯

terraform@puppet pmon2]$ sudo pmon2 run /home/terraform/go/src/happac/bin/happac --args "-h 10.132.204.203 -p 5556 -r 5001" --user terraform --name another FATA process already running with the name provided: happac

joe-at-startupmedia commented 10 months ago

first create an app with the test_server:

sudo pmon2 run bin/test_server --args "-h 10.132.204.203 -p 5556 -r 5001" --user terraform

now issue the same command again but with a different port argument

sudo pmon2 run bin/test_server --args "-h 10.132.204.203 -p 5555 -r 5000" --user terraform

We'll get:

FATA process already running with the name provided: test_server

Now we specify the name parameter.

sudo pmon2 run bin/test_server --args "-h 10.132.204.203 -p 5555 -r 5000" --user terraform  --name server-replica

Now ps shows two separate process with but pmon2 only shows 1!

root      404946       1  0 08:36 ?        00:00:00 /usr/local/pmon2/bin/pmond
terrafo+  404975       1  0 08:37 ?        00:00:00 /home/terraform/go/src/pmon2/bin/test_server -h 10.132.204.203 -p 5556 -r 5001
terrafo+  404999       1  0 08:40 ?        00:00:00 /home/terraform/go/src/pmon2/bin/test_server -h 10.132.204.203 -p 5555 -r 5000
[terraform@puppet pmon2]$ pmon2 ls
+----+----------------+--------+---------+-----------+-----+---------+---------------------+
| ID |      NAME      |  PID   | STATUS  |   USER    | CPU |   MEM   |        DATE         |
+----+----------------+--------+---------+-----------+-----+---------+---------------------+
| 1  | server-replica | 404999 | running | terraform | 0%  | 14.1 MB | 2023-12-31 08:40:44 |
+----+----------------+--------+---------+-----------+-----+---------+---------------------+
joe-at-startupmedia commented 10 months ago

It's because the previous developers are erroneously using process.process_file as a primary key in the persistence layer. https://github.com/joe-at-startupmedia/pmon2/blob/7ba346e93cc72d53a6cb5454db86dc5d78e6ff80/cli/service/add.go#L13

joe-at-startupmedia commented 10 months ago

Terminating all process and restarting pmond results in 3 process records all sharing the same pid:

[terraform@puppet pmon2]$ pmon2 ls
+----+------------------+--------+---------+-----------+-----+---------+---------------------+
| ID |       NAME       |  PID   | STATUS  |   USER    | CPU |   MEM   |        DATE         |
+----+------------------+--------+---------+-----------+-----+---------+---------------------+
| 1  |   test_server    | 406153 | running | terraform | 0%  | 13.8 MB | 2023-12-31 09:15:58 |
| 2  |  server-replica  | 406153 | running | terraform | 0%  | 13.8 MB | 2023-12-31 09:15:53 |
| 3  | server-replica-2 | 406153 | running | terraform | 0%  | 13.8 MB | 2023-12-31 09:15:58 |
+----+------------------+--------+---------+-----------+-----+---------+---------------------+
[terraform@puppet pmon2]$ ps -ef | grep pmon2
root      406131       1  0 09:15 ?        00:00:01 /usr/local/pmon2/bin/pmond
terrafo+  406153  406131  0 09:15 ?        00:00:00 /home/terraform/go/src/pmon2/bin/test_server -h 10.132.204.203 -p 5555 -r 5000