Running twistd as root, modules aren't found

前端 未结 1 1495
予麋鹿
予麋鹿 2021-01-19 19:34

I have a simple web server written in Twisted, and I\'m trying to start it up daemonized with twistd. Everything works fine with reactor.run()

相关标签:
1条回答
  • 2021-01-19 20:10

    General UNIX wisdom is that searching the working directory for things to execute when root is a bad idea. The argument goes that it opens the door to trojans. In not going out of its way to add the working directory to the Python module import search path when running as root, twistd is basically trying to follow this wisdom.

    As another commenter said, you can explicitly set PYTHONPATH yourself to include the directories which contain the code your app needs.

    You can also skip running as root entirely and use authbind to bind low-numbered ports without having superuser privileges. This is how all of my servers are deployed.

    0 讨论(0)
提交回复
热议问题