-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
starting additional PM2 start inside a script doesn't create a new pm2 #4761
Comments
If I run py test.py import random
from subprocess import Popen, PIPE, STDOUT
import time
while True:
variable = random.randint(1, 500)
print(f"hello {variable}")
Popen(f"where python", shell=True, universal_newlines=True)
time.sleep(3)
>>> hello 49
>>> C:\Users\PC\AppData\Local\Programs\Python\Python38\python.exe
>>> C:\Users\PC\AppData\Local\Microsoft\WindowsApps\python.exe if I run pm2 start test.py same code: >>> hello 123
>>> hello 32
>>> hello 41 I think the issue has something to do with that. when I launch a python script which launches another pm2, "watching" is enable... |
fix on going |
Please let me know if you need more information or if I can help you by performing some tests. 😄 Also out of curiosity, is there any ETA for the upcoming fix? |
You can try the fix:
then import subprocess
import random
import time
import os
print(f"hello {random.randint(1,500)}")
my_env = os.environ.copy()
my_env['PM2_PROGRAMMATIC'] = 'true'
subprocess.Popen(f'pm2 start test.py -name {random.randint(1,500)}', env=my_env, shell=True)
time.sleep(3) |
I havent tried Ubuntu/Linux yet but I tested through Windows. Right now nothing happens. I start the script by doing pm2 start test.py - It does print out:
but it does not create additional pm2 when it reaches the subprocess.Popen line. Not sure if its windows 10 64x related? |
Hello, if it can help, I have the same issue. Here is my use case.
When I do launch test1.py directly (without pm2: python3 test1.py), test2.py is correctly launched by pm2 and attached to the console. so I think that on top of the issue with the 2nd pm2 not being launched, there is also an issue leading to an infinite loop. I will continue to dig and let you know if I find anything. |
I can confirm it works very fine with Linux/Ubuntu but be aware of the fork bomb with my code. I would say to test @Krylanc3lo test.py & test2.py and add a long sleep between because there is two problems I would say:
Appreciate the fast help @Unitech ! <3 |
Thank you @Unitech for the quick fix |
I can confirm the fix works for Ubuntu! @Unitech However it doesn't seem to work for me using Windows 10 64x |
What's going wrong?
Hello guys!
I have figured out a new might be a bug or something that I have done wrong.
What I have found is that if you run a script that is already started with pm2 lets say we call it test.py and then inside the test.py I want to run another script with pm2 etc:
subprocess.Popen(f'pm2 start test.py -n hello_world', shell=True).communicate()
What should happen is that it should create a new pm2 task with a new name called hello_world. where the test.py is already ran by pm2 but the problem is that it never creates the second pm2 yet the test.py does run all the time.
How could we reproduce this issue?
import subprocess
import random
import time
print(f"hello {random.randint(1,500)}")
subprocess.Popen(f'pm2 start test.py -name {random.randint(1,500)}', shell=True)
time.sleep(3)
pm2 start test.py
it should create a new script called etc 312 (which is random) but it doesn't. The second pm2 gets never created.
Supporting information
The text was updated successfully, but these errors were encountered: