T
T
tshipenchko2021-04-29 08:06:35
Python
tshipenchko, 2021-04-29 08:06:35

How to run python modules with pm2?

An example of a command to run
python3 -m friendly-telegram

So far, I'm using a crutch with a file

# start.sh
python3 -m friendly-telegram

And I run

pm2 start start.sh --name ftg

Yes, maybe pm2 is not the best process manager for python. If you know better, please suggest. The ability to run binaries and js is also important to me

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2021-04-29
@tshipenchko

pm2 start python3 --name ftg -- -m friendly-telegram

D
DarkTM, 2021-04-29
@DarkTM

https://pm2.keymetrics.io/docs/usage/application-d...
Example for python:

{
    "apps": [{
        "name": "app_name",
        "script": "/the/app/path/my_app.py",
        "args": ["-c", "my_config.prod.json"],
        "instances": "1",
        "wait_ready": true,
        "autorestart": false,
        "max_restarts": 5,
        "interpreter" : "/path/to/venv/bin/python",
    }]
}

my advice is to just read about pm2 and experiment with it.

T
tshipenchko, 2022-04-11
@tshipenchko

In addition, you can do this:
pm2 start "any command with args" --name name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question