title: Linux: Start daemon on connected USB-serial dongle
body: <p>On my Linux (Angstrom distro on BeagleBone Black) I have a USB dongle which presents as  a serial port and per default is available as <code>/dev/ttyUSB0</code></p>
  
  <p>I want to start a daemon, which will connect to the serial port and make it available as a socket. I have the code for this USB-to-socket bridge and it works when started by hand.</p>
  
  <p>I want it to start automatically whenever the system boots, supposing the USB dongle is plugged in. How should I do this?</p>
  
  <p>Attempts so far:</p>
  
  <ol>
  <li><p>systemd: I created a systemd service with conditions <code>After: remote-fs.target</code> and <code>After:syslog.target</code> , but (it seems) the USB dongle is not ready at that point and the startup of the daemon fails.</p>
  
  <p>Are there other systemd <code>targets</code> or <code>services</code> to condition to, so that the daemon is started only when the udev has finished installing devices and the network is ready?</p></li>
  <li><p>udev: I created a udev rule like </p>
  
  <p>KERNEL=="ttyUSB?", RUN+="/path/to/daemon.sh"</p>
  
  <p>which executes successfully. But the daemon (which is started as a background process with a "&amp;" within that script) seems not to execute. Also it seems to be frowned upon, to fork long running processes from udev rules.</p></li>
  </ol>
  
  <p><strong>What is the correct way to do it?</strong></p>