【问题标题】:lighthttp, dbus, and myapp, without X11lighthttp、dbus 和 myapp,没有 X11
【发布时间】:2013-12-28 11:31:45
【问题描述】:

我在没有 X11 的系统上运行,“myapp”,它注册了一个 dbus 服务器, 一个 php 应用程序,它应该通过 dbus 向服务器发送消息。

在开发机器上一切正常,(使用 gnome,X11) 但是当我部署在没有 X11 的服务器上时,我会在每次 dbus 调用时运行:

# process status 
ps ax | grep dbus
2033 ?        Ss     0:00 /usr/bin/dbus-daemon --system
2383 pts/0    S+     0:00 grep --color=auto dbus


# listing names
dbus-send --session --print-reply --dest="org.freedesktop.DBus" /org/freedesktop/DBus  org.freedesktop.DBus.ListNames  
Failed to open connection to "session" message bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

# from php running with system("<above command> 2>&1"); I get same response

./myapp 
terminate called after throwing an instance of 'DBus::Error'
what():  Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Aborted
# same when calling into DBus::Connection bus = DBus::Connection::SessionBus();

如果我要向 ./.bashrc 添加以下脚本

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
    ## if not found, launch a new one
    eval `dbus-launch --sh-syntax --exit-with-session`
    echo "D-BUS per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
fi
#reboot
ps ax |grep dbus
2023 ?        Ss     0:00 /usr/bin/dbus-daemon --system
2389 pts/0    S      0:00 dbus-launch --sh-syntax --exit-with-session
2390 ?        Ss     0:00 /usr/bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
2392 pts/0    S+     0:00 grep --color=auto dbus

然后,从同一个外壳

dbus-send --session --print-reply --dest="org.freedesktop.DBus" /org/freedesktop/DBus  org.freedesktop.DBus.ListNames 

打印我的服务器名称,但来自 php

system("above command"); same error, and

system ("echo system("eval 'dbus-launch --auto-syntax' dbus-send --session --print-reply --dest=\"org.freedesktop.DBus\" /org/freedesktop/DBus  org.freedesktop.DBus.ListNames  2>&1");

没有列出名字。

问题是,如何从 lighthttpd 加入现有的 dbus 会话或任何其他变体。

谢谢

【问题讨论】:

    标签: x11 lighttpd dbus


    【解决方案1】:

    您已经编译了支持 x11 的 dbus。所以 dbus-launch 会产生问题。 尝试 $出口显示=:0 看看你是否可以使用 dbus-launch

    或直接启动守护进程 $ dbus-daemon --session --print-address 将地址导出到 DBUS_SESSION_BUS_ADDRESS

    【讨论】:

      【解决方案2】:

      谢谢, DISPLAY=:0 并没有完全解决问题。

      我没有在没有 X11 的情况下重新编译 dbus,但我正在使用 系统总线,一切正常。我必须使用系统总线 因为 lighttp 服务器通过 dbus.actualy 与服务通信
      我在 dbus 配置文件中启用了权限,就可以了。

      【讨论】:

        猜你喜欢
        • 2012-01-23
        • 2011-01-09
        • 2011-07-28
        • 1970-01-01
        • 2015-10-23
        • 2016-09-14
        • 1970-01-01
        • 2014-04-16
        • 1970-01-01
        相关资源
        最近更新 更多