【问题标题】:Raspberry Pi fhem web interface unreachableRaspberry Pi fhem Web 界面无法访问
【发布时间】:2013-10-17 13:37:16
【问题描述】:

今天我在 Raspberry Pi 上安装了 Arch Linux 并开始设置 fhem。使用 yaourt 安装 fhem 后,我自定义了 fhem 配置,编写了一个 systemd *.service 文件并使用以下命令启动服务:

sudo systemctl start fhem
sudo systemctl enable fhem

然后我使用 systemctl status fhem 检查了服务器状态,结果如下:

fhem.service - FHEM Perl Server
   Loaded: loaded (/etc/systemd/system/fhem.service; enabled)
   Active: inactive (dead) since Thu 2013-10-17 15:20:42 CEST; 11min ago
  Process: 480 ExecStart=/usr/bin/perl fhem.pl fhem.cfg (code=exited, status=0/SUCCESS)
 Main PID: 480 (code=exited, status=0/SUCCESS)

Oct 17 15:20:41 alarmpi systemd[1]: Started FHEM Perl Server.

所以服务器似乎正在运行,所以我切换到我的台式电脑并尝试通过将 firefox 指向 192.168.1.77:8083 来访问 fhem Web 界面:

Firefox can't establish a connection to the server at 192.168.1.77:8083 

所以我尝试通过 ssh 连接到 Raspberry Pi,效果很好。有人知道为什么我无法连接到 fhem 的 Web 界面吗?请在下面找到我的配置文件。

/etc/fhem/fhem.cfg

attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .                  # where our FHEM directory is
attr global statefile ./log/fhem.save  # where to save the state of the devices
attr global verbose 3                  # "normal" verbosity (min 1, max 5)

define telnetPort telnet 7072 global   # our TCP/IP port

define WEB FHEMWEB 8083 global

define WEBphone FHEMWEB 8084 global
attr WEBphone stylesheetPrefix smallscreen

define WEBtablet FHEMWEB 8085 global
attr WEBtablet stylesheetPrefix touchpad

# Fake FileLog entry, to access the fhem log from FHEMWEB 
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate autosave
attr autocreate device_room %TYPE
attr autocreate filelog ./log/%NAME-%Y.log
attr autocreate weblink
attr autocreate weblink_room Plots

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create 

/etc/systemd/system/fhem.service

[Unit]
Description=FHEM Perl Server
After=syslog.target network.target

[Service]
User=fhem
WorkingDirectory=/opt/fhem
ExecStart=/usr/bin/perl fhem.pl fhem.cfg
Type=simple 

[Install]
WantedBy=multi-user.target

/etc/iptables/iptables.rules

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p udp -m udp --dport 123 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A OUTPUT -p udp -m udp --sport 123 -j ACCEPT
COMMIT

【问题讨论】:

  • 首先,服务没有运行 Active: inactive (dead) since Thu 2013-10-17 15:20:42 CEST; 11 分钟前 Process: 480 ExecStart=/usr/bin/perl fhem.pl fhem.cfg (code=exited, status=0/SUCCESS) 如果有任何log-由fhem 生成的文件 然后查看它的退出原因。也许fhem 正在分叉?但是 hten systemd 应该捕获它的 PID。
  • 日志文件只是告诉我它加载了配置文件 fhem.cfg。这就是它没有更多的提示。

标签: raspberry-pi iptables archlinux systemd


【解决方案1】:

我能够使用以下 systemd 服务文件(主要修改为“Type=forking”)完成您想要实现的目标:

[Unit]                                                                                                 
Description=FHEM Perl Server                                                                           
After=syslog.target network.target                                                                     

[Service]                                                                                              
Type=forking                                                                                                           
User=fhem                                                                                              
WorkingDirectory=/opt/fhem                                                                             
ExecStart=/usr/bin/perl fhem.pl fhem.cfg

此外,由于您似乎使用的是“fhem”用户,请确保该用户对所需文件具有足够的权限(我必须至少为其授予对日志目录的写入权限)

仅供参考,在 AUR 中有一个用于 fhem 的包,即使它缺少此服务文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 2016-05-06
    相关资源
    最近更新 更多