1

I've got a simple .tac file with a simple service, I start it with:

twistd -y service.tac

and everything works fine. But inside the tac file I've got a hardcoded port for my service and I would like to make it dynamic. The most desired way I want to have it working is via standard unix command line arguments:

twistd -y service.tac --port 8081

and then I'd like to access the port variable somewhere inside the .tac file. Just like standard python modules: optparse and argparse. I was looking for such solution in Twisted, I found only https://twistedmatrix.com/documents/12.0.0/core/howto/options.html#auto6 which, I'm afraid, is not what I need, since I get this error:

$ twistd -y service.tac 
/usr/bin/twistd: option -y not recognized
/usr/bin/twistd: Try --help for usage details.

Does anyone know how to parametrize twistd tool?

ducin
  • 25,621
  • 41
  • 157
  • 256
  • possible duplicate of [twistd using usage.options in a \*.tac file](http://stackoverflow.com/questions/18244050/twistd-using-usage-options-in-a-tac-file) – Jean-Paul Calderone Nov 02 '13 at 11:27

1 Answers1

2

It looks as if the Twisted way of doing this is documented here:

https://twistedmatrix.com/documents/12.0.0/core/howto/tap.html

You write plugins that add 'subcommands' which can be used via the CLI

synthesizerpatel
  • 27,321
  • 5
  • 74
  • 91