0

I am testing my python script macro.py that runs in a loop from the terminal.

My plan is to code a Laravel application so that I can setup multiple instances of macro.py running on the server and these can be started and stopped at the any time.

Is this possible without too much difficulty?

Callum
  • 1,136
  • 3
  • 17
  • 43

1 Answers1

0

Invoke an external script the same way it is mentioned in this question. It's very important to store the process pid in any volatile memory (database, file). The retrieved pid number can be later used to stop the process using kill -9 process_pid command.

Be careful, if your python script "breaks" in the background (between your start and stop action called from application) there is a chance that the other process will retrieve the same pid number! I recommend to store also the process startup time as well as pid number. Before killing the process do the additional check of the stored startup time and kill the process only if test passed (otherwise assume that the process stopped unexpectedly and show appropriate information in the user interface).

Community
  • 1
  • 1
Wojciech Mleczek
  • 1,574
  • 15
  • 18