joe-at-startupmedia / pmon3

Golang Production Process Manager
10 stars 0 forks source link

How to more conveniently use /etc/pmon3/config/app.config.json to manage programs. #30

Closed BleethNie closed 3 months ago

BleethNie commented 3 months ago

I have the following issues. I have a Go web service and three external programs (Redis, Minio, Elasticsearch). I want to use pmon3 to control the start and stop of these four programs. For convenience, I have configured them in the /etc/pmon3/config/app.config.json file, and then used pmon3 init to start the programs.

joe-at-startupmedia commented 3 months ago

Issue 1

However, I found that the programs did not start. I am not quite clear whether my operation is correct, or how to use logs to query issues during the start-up process.

recent scheme change

Just to make sure, is this something you recently encountered since the 1.14.13 release? If so it's likely due to the fact that the schema changed which resulted in a breaking change. To remedy this, you must delete the sqlite database file before restarting the process.

systemctl stop pmond
rm -f /etc/pmond/data/data.db
systemctl start pmond

debugging

With regard to logging the process, the easiest way to do this is to start pmond with the following options:

log_level: debug

OR

PMON3_DEBUG=true pmond

followed by tailing the process logs:

tail -f /var/log/pmond/*.log

AND/OR

journalctl -u pmond -f

Issue 2

Because there is a priority relationship in the start-up of the above programs, pmon3 seems to currently not support the priority feature. Can a "dependency" feature be added (just a personal suggestion for a feature)?

I think this would be a useful feature, I've ran into scenario where I need it for myself. In addition to dependencies it would probably also be helpful to also use a priority property. I will create a separate issue to work on that

Issue 3

Sometimes I only want to start one of the services above. Is there a command pmon3 start redis to only start a single program in /etc/pmon3/config/app.config.json (In most scenarios, the programs deployed on the server are actually fixed, using pmon3 exec to start a program may be a more cumbersome operation, using pmon3 start may be more convenient)?

https://github.com/joe-at-startupmedia/pmon3?tab=readme-ov-file#applications-config

PMON3 currently prefers the SQLite database over the Apps config and only refers to the Apps config when the database doesn't exist or is empty. This is explained in further detail in the link above. Personally, I think this logic could use some improvement or at least the offering of a configuration parameter to always prefer the Apps Config over the database file.

To answer your question, start operates on processes saved in the database, not the Apps Config file (although the process in the database are a result of the Apps Config spec). As such yes, you can use start to start a single program but you would have to first kill all of the existing process. The database saves the state of the process which is persisted across run sessions.

The difference between start and exec is that exec inserts a new process into the database. If you're using the Apps Config feature, you'd want to instead place the process spec in Apps Config instead of using the exec command, this way the Apps Config serves as a single source of truth.


Keep in mind, with more configuration comes more complexity and more complexity = less usability for general users.

BleethNie commented 3 months ago

Thank you very much for your patient answers to my questions, which have been very helpful to me. For question 3, I would like to add some new ideas to see if it can change some of your thoughts:

image

Here, the apps config is just an entry point for quick startup, and the state saving is still in the database.

image

Here, the init command and the start command have the same functionality, but the init is a cyclic operation, so the start command will not increase complexity.

joe-at-startupmedia commented 3 months ago

start is currently simply an alias of restart. So treating it different from restart would entail breaking it into a separate cli command. This however would be unnecessary because they basically do the same thing which justifies them being an alias of eachother. Adding the ability to refer to an apps-config entry is still possible without separating the two.

The only scenario I foresee the applicability of referencing an apps-config entry would be when a config entry is added while the pmond is running without restart the process.

joe-at-startupmedia commented 3 months ago

@BleethNie I'll be testing this release candidate out over the next week before merging into master. It should meet most of the requirements discussed above: https://github.com/joe-at-startupmedia/pmon3/releases/tag/v1.15.0-alpha.1

BleethNie commented 3 months ago

It's very wonderful,I will also test whether the relevant functions are normal on my server

BleethNie commented 3 months ago

In my development environment, the program executes correctly using the apps config