Pm2: How to start a script in python's module type with pipenv?

Created on 17 Aug 2018  路  3Comments  路  Source: Unitech/pm2

I'm using the pipenv in my project, if I want to start a script through the way run as a module: python -m,so, my command like this:

pipenv run python -m scripts.script1

I don't know how to make this work with pm2, it seems that there is no document about this case:(

Although, I write the commands in a shell script like test.sh:

#!/usr/bin/env bash
pipenv run python -m scripts.script1

,and run the script with pm2:

pm2 start test.bash --interpreter bash

Sort of, it works.

I want to know a better way to achieve this,if it exists :)
Thank you in advance:)

Pending Deletion

Most helpful comment

Writing here for other people who want to know how to write the above command:

pm2 start "pipenv run python -m scripts.script1"

into an ecosystem file pm2.yml.
After some diggings:

apps:
    script: '/bin/bash' 
    name: 'script1'
    args:  ['-c', 'pipenv run python -m scripts.script1']

then,you can start the script1 in command line directly:

pm2 start pm2.yml

:)

All 3 comments

Hi @xzycn

You can try pm2 start "pipenv run python -m scripts.script1".

@wallet77 it works as expected, thank you :)
But, I think the usage should be written in documents :)

Writing here for other people who want to know how to write the above command:

pm2 start "pipenv run python -m scripts.script1"

into an ecosystem file pm2.yml.
After some diggings:

apps:
    script: '/bin/bash' 
    name: 'script1'
    args:  ['-c', 'pipenv run python -m scripts.script1']

then,you can start the script1 in command line directly:

pm2 start pm2.yml

:)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajendar38 picture rajendar38  路  3Comments

bragma picture bragma  路  4Comments

shaunwarman picture shaunwarman  路  3Comments

webchaz picture webchaz  路  3Comments

phra picture phra  路  3Comments