我在沒有X11的'myapp'系統上運行,它註冊了一個dbus服務器, 這是一個php應用程序,它應該通過dbus向服務器發送消息。lighthttp,dbus和myapp,沒有X11
一切工作濃煙在開發機器上,(與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會話或任何其他變體。
Thx