0

I'm using raspbian on a pi Zero to serve a simple static HTML page with an index.js and some styling.

I'm using the npm package http-server I've installed it globally. https://www.npmjs.com/package/http-server

In the terminal (using ssh), I've done http-server & to put the process into the background. However, I notice that the access logs still appear in the terminal.

Is this the proper way of actually putting a web server into the background?

On same note, how would someone also put a node process into the bg? I've only ever worked with PaSS where this was handled or with APache where there were service start commands.

Update..I'm doing this through SSH and so it is clearly not right way as process dies when I close my remote machine

Thanks!

1
  • What software is this web server? I mean, where you got it? I can't remember a linux http server which executable binary name would be just "http-server" Jul 13, 2022 at 3:26

1 Answer 1

2

Which service manager does your OS use? If that's systemd (which is common nowadays, Raspberry Pi OS uses it), you should to have a unit file for that service, either supplied with the package or created manually. Then, use generic

service start <name>

should be mapped to more general

systemctl start unit-name.service

where unit-name.service is the name of the unit file in the /etc/systemd/system or /lib/systemd/system. Also,

systemctl enable unit-name.service

will configure its automatic start when machine boots.

If you don't have a unit file, refer to systemd manual on how to create it (it's easy). If your system doesn't use systemd, refer to its documentation.


For one-time startups, also, nohup, screen or tmux programs may be used to decouple a process from the tty. If you need it to start automatically, this is not the correct way.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .