Apollo 星火计划踩坑记录 dreamview启动报错“No such file or directory: ‘ping‘: ‘ping‘”

4 篇文章 0 订阅
2 篇文章 0 订阅

第一次以计算机科学与技术本科生身份写blog也是值得纪念的

百度Apollo开源社区近期开始了“星火计划第二期”,使用了新版本的工程框架,但是毕竟还在测试中,小bug不可避免,这篇blog记录一下很多开发者们遇到的这个问题。

以下是报错内容

jingqiao@in-dev-docker:/apollo_workspace$ bash scripts/apollo_neo.sh bootstrap start
Traceback (most recent call last):
  File "/usr/bin/buildtool", line 216, in <module>
    sys.exit(main() or 0)
  File "/usr/bin/buildtool", line 206, in main
    obj = PackageBuilder()
  File "/usr/bin/buildtool", line 75, in __init__
    self.entry_points = EntryPoints(entry_points_path, root_path, subparsers) 
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/entry_point.py", line 112, in __init__
    self.actions[verb] = all_lib_entry_points[verb].Action()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/build.py", line 51, in __init__
    super().__init__()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/__init__.py", line 63, in __init__
    self.decider = DeciderInterface()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/decider.py", line 139, in __init__
    self.metadata_cli = MetaDataCli()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/cyberfile/__init__.py", line 41, in __init__
    self.procedure = Procedure()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 46, in __init__
    self._ping_network()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 50, in _ping_network
    if subprocess.call(cmd) != 0:
  File "/usr/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ping': 'ping'
[buildtool] INFO apollo build tool exit.
Traceback (most recent call last):
  File "/usr/bin/buildtool", line 216, in <module>
    sys.exit(main() or 0)
  File "/usr/bin/buildtool", line 206, in main
    obj = PackageBuilder()
  File "/usr/bin/buildtool", line 75, in __init__
    self.entry_points = EntryPoints(entry_points_path, root_path, subparsers) 
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/entry_point.py", line 112, in __init__
    self.actions[verb] = all_lib_entry_points[verb].Action()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/build.py", line 51, in __init__
    super().__init__()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/action/__init__.py", line 63, in __init__
    self.decider = DeciderInterface()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/decider.py", line 139, in __init__
    self.metadata_cli = MetaDataCli()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/version_decide/cyberfile/__init__.py", line 41, in __init__
    self.procedure = Procedure()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/package_identification/identifier.py", line 40, in inner
    _instance[cls] = cls()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 46, in __init__
    self._ping_network()
  File "/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py", line 50, in _ping_network
    if subprocess.call(cmd) != 0:
  File "/usr/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ping': 'ping'
[buildtool] INFO apollo build tool exit.
[ERROR] Failed to start Dreamview. Please check dreamview.log or monitor.log for more information

分析报错信息可以发现问题出在ping上面。通过查看代码会发现核心问题在此文件中

/opt/apollo/neo/packages/buildtool-dev/1.0.0.1/core/task/bazel/handler/__init__.py

以下就是导致报错的代码

    def _ping_network(self):
        cmd = ["ping", "-c", "1", "baidu.com"]
        if subprocess.call(cmd) != 0:
           self.online = False

有开发者使用将 if 直接注释掉解决了这个问题,博主亲测是可以的。简单分析下这个代码,这是一段检查网络的代码,ping baidu.com以测试网络。有开发者猜测可能是网络问题,但是国内baidu不可能连不上,看下报错内容提示是没有 ping。一般docker中使用的Ubuntu都是经过裁剪的,缺胳膊少腿是正常现象,所以我猜测可能是docker环境没有安装ping导致的,于是进行以下测试

jingqiao@in-dev-docker:/apollo_workspace$ ping www.baidu.com
bash: ping: command not found

果然是没有安装ping的问题,那问题就很好解决了

sudo apt install iputils-ping

再次测试

jingqiao@in-dev-docker:/apollo_workspace$ ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=49 time=33.7 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=49 time=35.0 ms
jingqiao@in-dev-docker:/apollo_workspace$ bash scripts/apollo_neo.sh bootstrap
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=46 time=45.4 ms

--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 45.453/45.453/45.453/0.000 ms
[buildtool] INFO Reconfigure apollo enviroment setup
[buildtool] INFO Done! Please activate the apollo enviroment setup by following command:
[buildtool] INFO 	source ~/.bashrc
[buildtool] INFO apollo build tool exit.
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=46 time=33.4 ms

--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 33.496/33.496/33.496/0.000 ms
[buildtool] INFO Reconfigure apollo enviroment setup
[buildtool] INFO Done! Please activate the apollo enviroment setup by following command:
[buildtool] INFO 	source ~/.bashrc
[buildtool] INFO apollo build tool exit.
[INFO] Dreamview is running at http://localhost:8888

问题就解决了。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java中的`OutOfMemoryError: Java heap space`误表示JVM(Java Virtual Machine)没有足够的内存来执行当前的操作。这是因为当Java程序在运行过程中消耗的内存超过了JVM所分配的最大堆空间。以下是一些解决这种误的方法: 1. 增加JVM内存: - 在启动Java应用时,可以通过命令行参数 `-Xmx` 来设置最大堆大小,例如 `-Xmx2g`,这里`2g`代表2GB内存。确保有足够的物理内存可用。 - 如果是通过IDE(如IntelliJ IDEA或Eclipse)运行,可以在运行配置中修改JVM参数。 2. 使用堆内存分段(如G1 Garbage Collector): - 如果可能,考虑使用现代的垃圾收集器G1,它更擅长处理大内存的应用场景,可能会减少内存碎片和停顿时间。 3. 减少内存泄漏: - 检查代码是否有内存泄漏,比如未关闭的流、对象引用导致的循环引用等。使用内存分析工具如VisualVM、JProfiler等帮助定位。 4. 批量处理或分批加载数据: - 如果是大数据操作,尝试分批处理,而不是一次性加载所有数据到内存。 5. 优化代码: - 可能的话,优化算法和数据结构,避免不必要的内存消耗。 6. 使用Off-Heap内存: - 如果可能,使用NIO(Non-blocking I/O)或`sun.misc.Unsafe`进行一些非Java对象的内存管理。 相关问题: 1. 什么是JVM的最大堆空间? 2. 如何在运行时动态调整JVM内存? 3. 为什么垃圾收集器的类型会影响内存管理? 请告诉我,您是否遇到特定的信息,或者需要了解哪些方面的详细解决方案?

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值