1
我有一个简单的服务的简单.tac文件,我开始吧:扭曲的twistd来解析工具的命令行参数
twistd -y service.tac
,一切工作正常。但是在tac文件中,我有一个硬编码的端口用于服务,我想使其动态化。最想要的方式,我想拥有它的工作是通过标准的UNIX命令行参数:
twistd -y service.tac --port 8081
,然后我想某处访问.tac文件中的port
变量。就像标准的Python模块一样:optparse和argparse。我一直在寻找扭转这样的解决方案,我发现只有https://twistedmatrix.com/documents/12.0.0/core/howto/options.html#auto6其中,我很害怕,是不是我所需要的,因为我得到这个错误:
$ twistd -y service.tac
/usr/bin/twistd: option -y not recognized
/usr/bin/twistd: Try --help for usage details.
有谁知道如何参数化twistd
工具?
可能重复使用“子”插件在\ *。tac文件中使用usage.options](http://stackoverflow.com/questions/18244050/twistd-using-usage-options-in-a-tac-file) –