I am developing a ban system based on iptables.
So I need to run a service that will accept incoming rpc for settings & querying iptables rules.
On nameko run some setup procedures should be called like creating new iptables chains etc.
But this must be run only once on startup.
So I am trying to use a SharedExtension. Like this:
class SecurityExtension(DependencyProvider): def get_dependency(self, worker_ctx): for ext in self.container.extensions: if isinstance(ext, SecurityManager): return ext logger.error('Cannot find SecurityManager!') class SecurityManager(SharedExtension, ProviderCollector): filter_ports =  def setup(self): self.filter_ports = ['5060'] # TODO: Get from server or directly from asterisk AMI logger.info('Security filter ports: %s', self.filter_ports) class SecurityBroker: name = 'security' manager = SecurityExtension() @rpc def test(self): return self.manager.filter_ports
But test() always returns  and setup never is called.
So if I add a new Entrypoint class it works:
class SecurityEvent(Entrypoint): manager = SecurityManager() security = SecurityEvent.decorator
and add the following method to SecurityBroker class:
@security def security_stub(): pass
And all works.
But I have a question if there is another way to setup some code on startup of nameko run.