start_stop_deamon - does not take deamon arguments - Please advise

Hi,

I have a need to invoke Python Program as deamon. I have created /etc/init.d scipt. Since I am distributing Pyo files only I need to run this using python -O myapp.pyo

Here is the start_stop_deamon command ( I have stripped everything except the main one)

start-stop-daemon -S -m -p -s /var/run/my-app.pid -x/usr/bin/python2.7 -O /root/myapp.pyo

Problem is,

start_stop_deamon thinks -O is not valid option.

I tried with quotes, double quotes, etc. But this does not run
start-stop-daemon -S -m -p -s /var/run/my-app.pid -x"/usr/bin/python2.7 -O /root/myapp.pyo"

Any Ideas, how to specify -O option.

Please any advice is highly appreciated

Regards

BRE

nano  /root/myapp.py
#!/usr/bin/python
...
chmod 755  /root/myapp.py
start-stop-daemon -S -m -p -s /var/run/my-app.pid -x /root/myapp.py

Sonnyyu,

Thank you very much for the reply- Sorry for my delay

In this example /root/myapp.py

If want to distribute only myapp.pyo files then it requires an -O option to run: python -O /root/myapp.pyo

With this context - I cannot bring -O into
start-stop-daemon -S -m -p -s /var/run/my-app.pid -x -O /root/myapp.pyo

I get an error -O is not valid option

Thank you very much for the reply

Sincere Regards

BRE

Use .pyo file for security purpose? hide source code?

BREL, wrap the python script with a bash script. This script will invoke python with -O

sonnyyu, using -O reduces python VM startup time (since your second run, first one will be slower). As often mentioned, with -O flag your program will NOT run faster, it will just START faster, because python won't need to compile the script

Federico,

Thank you very much for the reply,
Currently I am distributing only a.pyc files ( bytecode) which does not need any arguments and serve almost same purpose as pyo files,

Though, I prefered pyo files, let me try out your option.

Sonnyyu,

Use .pyo file for security purpose? hide source code?

Yes- mainly for security

Thank you very much for the reply

My sincere regards

BRE