elviejokike / flask-eureka Goto Github PK
View Code? Open in Web Editor NEWFlask Eureka Integration
License: MIT License
Flask Eureka Integration
License: MIT License
I have registried my microservice to eureka, but how to call other microservices using flask-eureka?
While trying to register flask service, Eureka client tries to get ipv4 with this code:
def ipv4(self): if self.system == 'Darwin': ipv4 = getoutput("ifconfig " + self.iface + " | grep 'inet ' | awk '{ print $2 }'") else: ipv4 = getoutput("ifconfig " + self.iface + " | grep 'inet addr' | awk '{ print $2 }'") ipv4 = ipv4.split(':')[1]
Here command ifconfig is called in terminal. However, there's no such command in Windows terminal, so getoutput function result is '"ifconfig" Ґ пў«пҐвбп ўгв॥© Ё«Ё ўҐиҐ© Є®¬ ¤®©, ЁбЇ®«пҐ¬®© Їа®Ја ¬¬®© Ё«Ё Ї ЄҐвл¬ д ©«®¬.'. By decoding this, I get '"ifconfig" не является внутренней или внешней командой, исполняемой программой или пакетным файлом.', which is the message that command was not found in Russian. Unsuprisingly, the whole library won't work on Windows.
Traceback (most recent call last):
File "app2.py", line 17, in <module>
eureka.register_service(name="my-flask-service")
File "/home/modak/Codebase/Modak/git_repos/enod-ws-v2.0/flask_eureka/eureka.py", line 57, in register_service
**kwargs)
File "/home/modak/Codebase/Modak/git_repos/enod-ws-v2.0/flask_eureka/eurekaclient.py", line 93, in __init__
host_info = HostInfo().get()
File "/home/modak/Codebase/Modak/git_repos/enod-ws-v2.0/flask_eureka/hostinfo.py", line 35, in get
'IPv4': self.ipv4(),
File "/home/modak/Codebase/Modak/git_repos/enod-ws-v2.0/flask_eureka/hostinfo.py", line 54, in ipv4
ipv4 = ipv4.split(':')[1]
IndexError: list index out of range
==============================================================
Running on VMWare Ubuntu 16.04
ubuntu $ ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:03:58:88:94
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:3ff:fe58:8894/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:270 errors:0 dropped:0 overruns:0 frame:0
TX packets:516 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:213329 (213.3 KB) TX bytes:80733 (80.7 KB)
ens33 Link encap:Ethernet HWaddr 00:0c:29:35:45:d4
inet addr:192.168.206.135 Bcast:192.168.206.255 Mask:255.255.255.0
inet6 addr: fe80::52f2:ed1:d777:2587/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:94076 errors:0 dropped:0 overruns:0 frame:0
TX packets:53932 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:92354926 (92.3 MB) TX bytes:6995641 (6.9 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:39081 errors:0 dropped:0 overruns:0 frame:0
TX packets:39081 errors:0 dropped:0 overruns:0 carrier:0
Hi,
I got a running Spring Netflix Eureka Server and tried to connect a flask client to it.
When I try to start the Flask Server I get the following error message and I can't find out where the error is.
Der Befehl ""ifconfig en0 | grep 'inet addr' | awk '{ print $2 }'"" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Traceback (most recent call last):
File "C:/Projects/PDA/web-crawler-service/webcrawlerservice/WebCrawlerService.py", line 62, in <module>
connect_to_eureka()
File "C:/Projects/PDA/web-crawler-service/webcrawlerservice/WebCrawlerService.py", line 33, in connect_to_eureka
eureka.register_service(name="my-flask-service")
File "C:\Projects\playground\venv1\lib\site-packages\flask_eureka\eureka.py", line 57, in register_service
**kwargs)
File "C:\Projects\playground\venv1\lib\site-packages\flask_eureka\eurekaclient.py", line 95, in __init__
host_info = HostInfo().get()
File "C:\Projects\playground\venv1\lib\site-packages\flask_eureka\hostinfo.py", line 34, in get
'IPv4': self.ipv4(),
File "C:\Projects\playground\venv1\lib\site-packages\flask_eureka\hostinfo.py", line 52, in ipv4
ipv4 = getoutput("ifconfig " + self.iface + " | grep 'inet addr' | awk '{ print $2 }'")
File "C:\Projects\playground\venv1\lib\site-packages\flask_eureka\hostinfo.py", line 10, in getoutput
return subprocess.check_output([cmd], shell=True)
File "C:\Python27\Lib\subprocess.py", line 219, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '["ifconfig en0 | grep 'inet addr' | awk '{ print $2 }'"]' returned non-zero exit status 1
Attached you can find my configuration file and the python script which I am running.
My Spring Eureka Server has the following configuration:
spring:
application:
name: eureka-service
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/
Thanks
在hostInfo.py文件里面没有找到关于windows系统的命令提取
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.