0
votes

I am using systemd to start an executable at boot time on a single board computer (embedded) platform. I want this app to run in headless mode - no logging in - and the user will control the input through a web browser.

I am using a TS-7800-V2 which runs Debian.

Here is my service (webserver.service) set up (etc/systemd/system):

[Unit]
Description=Run LWSWS webserver on startup
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=simple
ExecStart=/libwebsockets/build/bin/lwsws

[Install]
WantedBy=multi-user.target

I have enabled and started the service, and checked the status:

root@ts7800-v2:~# systemctl status webserver.service 
��● webserver.service - Run LWSWS webserver on startup
   Loaded: loaded (/etc/systemd/system/webserver.service; enabled; vendor preset
   Active: active (running) since Mon 2017-12-11 11:23:39 PST; 11min ago
 Main PID: 2408 (lwsws)
   CGroup: /system.slice/webserver.service
       ��└��─2408 /libwebsockets/build/bin/lwsws

Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]:    mounting callback://proto
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]:  Using non-SSL mode
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: created client ssl context f
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: Unable to find interface eth
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: init server failed
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: Failed to create vhost local
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: /etc/lwsws/conf.d/test-serve
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: lwsws[2416]: Context creation failed
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: GPS THREAD created successfully
Dec 11 11:23:39 ts7800-v2 lwsws[2408]: MOTOR CONTROL THREAD created successfully

So, the service is active and running, but the eth0 connection is not being made so that the web server (libwebsockets web server LWSWS) cannot start up properly.

My question is how to get Ethernet to startup on boot so that the web server can start up and run?

In the dependencies for this service, the networking shows in the tree before the rest of the service startup:

root@ts7800-v2:/etc/systemd/system# systemctl list-dependencies webserver.service
��● ��├��─system.slice
��● ��├��─network-online.target
��● ��│ ��└��─networking.service
��● ��└��─sysinit.target
��●   ��├��─dev-hugepages.mount
��●   ��├��─dev-mqueue.mount
��●   ��├��─kmod-static-nodes.service
��●   ��├��─proc-sys-fs-binfmt_misc.automount
��●   ��├��─sys-fs-fuse-connections.mount
��●   ��├��─sys-kernel-config.mount
��●   ��├��─sys-kernel-debug.mount
��●   ��├��─systemd-ask-password-console.path
��●   ��├��─systemd-binfmt.service
��●   ��├��─systemd-hwdb-update.service
��●   ��├��─systemd-journal-flush.service
��●   ��├��─systemd-journald.service
��●   ��├��─systemd-machine-id-commit.service
��●   ��├��─systemd-modules-load.service
��●   ��├��─systemd-random-seed.service
��●   ��├��─systemd-sysctl.service
��●   ��├��─systemd-timesyncd.service
��●   ��├��─systemd-tmpfiles-setup-dev.service

Advice on how to get the network started before the web server starts would be appreciated. Thanks!

2

2 Answers

1
votes

I think you are missing managing of a network interface. Something like NetworkManager. If you are already using systemd maybe systemd-networkd is a solution for you. Please read systemd-networkd from ArchLinux Wiki for reference.

0
votes

I had to get the ethernet connection to auto-start when the app is in headless mode. Here is the contents (cat) of the etc/network/interfaces file:

root@ts7800-v2:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

I added the line "auto eth0" and now ethernet is started up before my webserver.service is called.