dongxi7609 2018-08-03 07:41 采纳率: 0%
浏览 92

启动自定义init.d脚本会导致在localhost上找不到404页面

I have an executable server file written in Golang which is ran by a custom script file, located in /etc/init.d/ directory on my Raspberry Pi 3B. The server starts but doesn't display the website I made in HTML. This website is located in a "static" folder in the same directory as my server executable.

I used this command to build the server.go into an executable.

go build server.go

NOTE

If I start the server manually by double-clicking it, the website works fine (my server displays the "static" folder).

My static folder consists of html, javascript and css files.

I think the problem is that when I start the server by a script, the static folder is not found by the server (displays: 404 page not found).

I would also like that the script is started whenever the RPi is booted.

I wrote the script following this site: https://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html

Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • dpqjvoq9033 2018-08-03 07:50
    关注

    This is more of a question of system admin, so maybe better suited to https://serverfault.com/

    That said, sounds like you want to set WorkingDirectory in your systemd unit so it can find your files (if using systemd).

    WorkingDirectory=/path/to/server/dir
    

    Adrian points out below that if you're using a bash script (as this is an old article) perhaps just add:

    cd /path/to/server/dir
    
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行