Search code examples
c++node.jsshellyoctoautostart

autostart webserver and programm


I'm working on a Yocto based system. My problem is that I can't start my programm written in C++ and the webserver (node.js) at the same time right after the boot of my device.

I already tried this in /etc/init.d:

#! /bin/bash
/home/ProjectFolder/myProject
cd /home/myapp && DEBUG=myapp:* npm start

exit 0

I changed the rights after creating the script by

chmod +x ./startProg.sh

After that I linked it by

update-rc.d startProg.sh defaults

After reboot the system only starts the C++-programm. I tried some other possibilities like seperating the two comands in different shell-scripts, but that didn't work out any better.

Is there any option I missed or did I make any mistake trying to put those two processes into the autostart?


Solution

  • This of course isn't a C++ or Node.js question. A shell script is a list of commands that are executed in order, unless specified otherwise. So your shell script runs your two programs in the order specified, first myProject and when that's done npm will be started.

    This is the same as what would happen from the prompt and the solution is the same: /home/ProjectFolder/myProject &