I’m running a systemd unit to configure and bring up the CAN interfaces. There is a big delay before my systemd unit gets run. What could be causing this? I hope to run my application as a systemd unit as well, and it needs to boot as fast as possible. See the dmesg output below.
It seems like I can ssh and start a session before the systemd runs my can-bus-start.service. Perhaps I have it misconfigured. I want it to start as soon as possible so I can then start another service running my application.
There is a lot of syslog in the attached file. syslog.txt (229.3 KB)
$ cat /etc/systemd/system/can-bus-start.service
[Unit]
Description=Bring up can0 and can1
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip link set can0 type can bitrate 500000 restart-ms 100 ; /sbin/ifconfig can0 up ; /sbin/ip link set can1 type can bitrate 500000 restart-ms 100 ; /sbin/ifconfig can1 up
ExecReload=/sbin/ifconfig can0 down ; /sbin/ifconfig can1 down ; /sbin/ip link set can0 type can bitrate 500000 restart-ms 100 ; /sbin/ifconfig can0 up ; /sbin/ip link set can1 type can bitrate 500000 restart-ms 100 ; /sbin/ifconfig can1 up
ExecStop=/sbin/ifconfig can0 down ; /sbin/ifconfig can1 down
[Install]
WantedBy=multi-user.target
$ systemctl status can-bus-start
* can-bus-start.service - Bring up can0 and can1
Loaded: loaded (/etc/systemd/system/can-bus-start.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2024-11-19 09:42:35 NZDT; 27min ago
Process: 6314 ExecStart=/sbin/ifconfig can1 up (code=exited, status=0/SUCCESS)
Process: 6267 ExecStart=/sbin/ip link set can1 type can bitrate 500000 restart-ms 100 (code=exited, status=0/SUCCESS)
Process: 6263 ExecStart=/sbin/ifconfig can0 up (code=exited, status=0/SUCCESS)
Process: 6250 ExecStart=/sbin/ip link set can0 type can bitrate 500000 restart-ms 100 (code=exited, status=0/SUCCESS)
Main PID: 6314 (code=exited, status=0/SUCCESS)
Nov 19 09:42:35 sampextx2 systemd[1]: Starting Bring up can0 and can1...
Nov 19 09:42:35 sampextx2 systemd[1]: Started Bring up can0 and can1.
I am running a samba share and the tx2 is connected to wifi. Perhaps I could start my can bus config on a different target? Sorry, I’m new to all this stuff!
$ systemd-analyze critical-chain
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.
graphical.target @2min 1.271s
`-multi-user.target @2min 1.267s
`-smbd.service @2min 1.099s +168ms
`-nmbd.service @2min 793ms +303ms
`-network-online.target @2min 773ms
`-network.target @1.840s
`-NetworkManager.service @1.087s +752ms
`-dbus.service @952ms
`-basic.target @772ms
`-sockets.target @772ms
`-snapd.socket @765ms +6ms
`-sysinit.target @761ms
`-sys-fs-fuse-connections.mount @4.833s +11ms
`-systemd-modules-load.service @300ms +181ms
`-systemd-journald.socket @264ms
`-system.slice @261ms
`--.slice @257ms
I made the can-bus-start.service start after network.target and it still works so that gets around waiting for the network to come online. It is still a bit strange that it takes about 2 minutes to get the network online, but probably not an issue for me.