Restarting Apache from Django -
i need django app able restart apache server running it. i'm using mod_python.
which easiest way?
the way possible if gave django application root permissions, horribly unsafe. but, assuming app running root, can run
import subprocess subprocess.popen(['/etc/init.d/apache2', 'restart'])
or whatever command distribution has restarting apache. if django app not root, may able run sudo
using pexpect python library.
import pexpect child = pexpect.spawn('sudo /etc/init.d/apache2 restart') child.expect('[sudo] password .*:') child.sendline(password) child.interact()
note way requires give apache user ability run sudo
insecure. in general, can't see secure way accomplish this.
Comments
Post a Comment