# How to trigger some rpc entrypoints when service is started?

**URL:** <https://discourse.nameko.io/t/how-to-trigger-some-rpc-entrypoints-when-service-is-started/562>\
**Category:** googlegroup\
**Created:** [March 15, 2020, 1:12pm UTC](https://discourse.nameko.io/t/how-to-trigger-some-rpc-entrypoints-when-service-is-started/562 "2020-03-15T13:12:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![melonux](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/melonux/32/57_2.png) [@melonux](https://discourse.nameko.io/u/melonux)\
**Post date:** [March 15, 2020, 1:12pm UTC](https://discourse.nameko.io/t/how-to-trigger-some-rpc-entrypoints-when-service-is-started/562/1 "2020-03-15T13:12:32Z")

</div>

I want to call several rpc entrypoints when my service is started. My solution is below. But it has fault.

```
def main():
    runner = create_service_runner(cfg['nameko'])
    runner.start()

    if not on_service_start(cfg['nameko']):
        raise RuntimeError('Failed to setup service.')
    runner.wait()

def on_service_start(cfg) -> bool:
    with ServiceRpcProxy('my_service', cfg['nameko'], timeout=5 * 60) as rpc:
        return rpc.init1() and rpc.init2()

```

eventlet blames below. Furthermore, if my\_service is deployed in a cluster, it cannot guarantee all nodes get correct amount of rpc requests.

> nameko.exceptions.RemoteError: RuntimeError Second simultaneous read on fileno 6 detected. Unless you really know what you’re doing, make sure that only one greenthread can read any particular socket. Consider using a pools.Pool. If you do know what you’re doing and want to disable this error, call eventlet.debug.hub\_prevent\_multiple\_readers(False) - MY THREAD=\<built-in method switch of GreenThread object at 0x7f477efa8c00\>; THAT THREAD=FdListener(‘read’, 6, \<built-in method switch of GreenThread object at 0x7f478016e470\>, \<built-in method throw of GreenThread object at 0x7f478016e470\>)

Is there a better way to call ‘my\_service’ entrypoint in ‘my\_service’ project itself?

---

<div class="post-metadata">

**Author:** ![litmax](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/litmax/32/67_2.png) [@litmax](https://discourse.nameko.io/u/litmax)\
**Post date:** [March 20, 2020, 4:32pm UTC](https://discourse.nameko.io/t/how-to-trigger-some-rpc-entrypoints-when-service-is-started/562/2 "2020-03-20T16:32:06Z")

</div>

I do it like this:

```python
from nameko.extensions import Entrypoint

class Start(Entrypoint):

    def start(self):
        self.container.spawn_worker(self, (), {})

on_start = Start.decorator

class OdooService:
    name = 'odoo'

    @on_start
    def on_service_start(self):
        logger.debug('Odoo service start.')

```
