Skip to content
Advertisement

how to make the progame start only one process?

I have a python project using python stand lib socketserver to listening on a tcp socket for data receiving.

I create a one-single executable file using pyinstaller, now I run the binary program on linux, there are two process.

[root@localhost vmagent]# ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b &
[1] 19236
[root@localhost vmagent]# ps -ef|grep vmagent
root     16475 16364  0 14:09 pts/2    00:00:00 tail -30f vmagent.log
root     19236 18581  2 15:21 pts/6    00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19246 19236  8 15:21 pts/6    00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19263 18581  0 15:22 pts/6    00:00:00 grep vmagent
[root@localhost vmagent]# 

After exit the current session and re-login, there are still two process. How can I do make the program only one process?

[root@localhost ~]# ps -ef|grep vmagent
root     16475 16364  0 14:09 pts/2    00:00:00 tail -30f vmagent.log
root     19236     1  0 15:21 ?        00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19246 19236  0 15:21 ?        00:00:00 ./vmagent 10.20.248.37 e93773b6-d04a-40b2-9c57-f4ff6995309b
root     19542 19505  0 15:34 pts/5    00:00:00 grep vmagent
[root@localhost ~]# 

Advertisement

Answer

It seems that is how pyinstaller works. Please check this part of the documentation https://pythonhosted.org/PyInstaller/advanced-topics.html#the-bootstrap-process-in-detail.

So your binary was not started twice, it’s just that pyinstaller uses two processes.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement