Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not registering/retrying if Eureka was restarted #11

Open
ac9962 opened this issue Mar 23, 2018 · 0 comments
Open

Not registering/retrying if Eureka was restarted #11

ac9962 opened this issue Mar 23, 2018 · 0 comments

Comments

@ac9962
Copy link

ac9962 commented Mar 23, 2018

Version

wasp_eureka==1.1.1_

What did you do?

This is my code to register my service to Eureka.

import logging
from threading import Thread
import asyncio
from wasp_eureka import EurekaClient
loop = asyncio.get_event_loop()

async def main(app_name=None, port=None, ip=None, eureka_url="myEurekaurl"):
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.info(f"registering service: {app_name}, {ip}, {port}, {eureka_url}")
eureka = EurekaClient(app_name, port, ip, eureka_url=eureka_url, loop=loop)
result = await eureka.register()
print(f'service resisted {result}')
lease_renewal_cnt = 0
while True:
lease_renewal_cnt += 1
print('Eureka Lease Renewal Count: ', lease_renewal_cnt)
await asyncio.sleep(67)
await eureka.renew()

class EurekaThread(Thread):
def init(self, app_name, port, ip, eureka_url):
Thread.init(self)
self.app_name = app_name
self.port = port
self.ip = ip
self.eureka_url = eureka_url

def run(self):
    loop.run_until_complete(main(self.app_name, self.port, self.ip, self.eureka_url))

What did the code do?

I call class EurekaThread(app_name, port, host, eurekaUrl).start() for registering which runs on separate thread.

Please post exactly what the code did, including a stack-trace is helpful.

2018-03-23 10:48:30,761 - root - INFO - registering service: my-service, localhost, 44368, http://localhost:8765/
2018-03-23 10:48:30,761 - wasp.eureka - DEBUG - Status page not provided, rewriting to http://localhost:44368/info
2018-03-23 10:48:30,761 - wasp.eureka - DEBUG - Generated new instance id: 98413bdb-cfd0-4e7b-8eeb-15c0db7e7bcd:my-service:44368 for app: my-service
2018-03-23 10:48:30,761 - wasp.eureka - DEBUG - Registering my-service
2018-03-23 10:48:30,762 - wasp.eureka - DEBUG - Performing POST on /apps/my-service with payload: {"instance": {"instanceId": "98413bdb-cfd0-4e7b-8eeb-15c0db7e7bcd:my-service:44368", "leaseInfo": {"durationInSecs": 60, "renewalIntervalInSecs": 15}, "port": {"$": 44368, "@enabled": true}, "hostName": "localhost", "app": "my-service", "ipAddr": "localhost", "vipAddress": "my-service", "dataCenterInfo": {"@Class": "com.netflix.appinfo.MyDataCenterInfo", "name": "MyOwn"}, "statusPageUrl": "http://localhost:44368/info"}}
2018-03-23 10:48:30,772 - werkzeug - INFO - * Running on http://localhost:port/ (Press CTRL+C to quit)
2018-03-23 10:48:30,792 - wasp.eureka - DEBUG - Result: 204
2018-03-23 10:49:37,836 - wasp.eureka - DEBUG - Performing PUT on /apps/my-service/98413bdb-cfd0-4e7b-8eeb-15c0db7e7bcd:my-service:44368 with payload: None

What did you expect?

Expected to it to retry or registering back if Eureka service is back on restart but instead this get stuck last log statement in above section.

Please outline the expected behavior
logger.debug('Performing %s on %s with payload: %s', method, path,
data)
async with _SESSION.request(method, url, data=data) as resp:
if 400 <= resp.status < 600:
# noinspection PyArgumentList
raise EurekaException(HTTPStatus(resp.status),
await resp.text())
logger.debug('Result: %s', resp.status)

Helpful others:

  • See here for help on how to ask good questions.
  • Be sure to use code formatting (```python) for blocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant