启动自定义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.

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