2

I want to write a script which basically runs my node server first and after only node server has started I want to run another script. How can I implement this using shell script?

Right now I have done this so far

echo "Going inside NodeServer folder";
cd ./../Server-Node
echo "Starting Node Server";
npm start
echo 'Going inside Project Folder';
cd ./../ionicApp
ionic serve
Abhishek Gangwar
  • 2,168
  • 18
  • 26

2 Answers2

2

A simple hack is to use npm start & add a sleep 15 on the line after it (or adjust accordingly to the avg time the start takes).

Note: to terminate the node process you might have to run a command to kill it stop all instances of node.js server

Otherwise you'll want to look at some stuff here NPM run parallel task, but wait until resource is available to run second task

DavidX
  • 1,281
  • 11
  • 16
1

I found out this later. adding modified script

echo "Going inside Server-Node";
cd ./../Server-Node
echo "Starting Node Server";
npm start & echo OK
echo 'Going inside ionic-Project';
cd ./../learn-ionic
echo 'Starting ionic server';
ionic serve
Abhishek Gangwar
  • 2,168
  • 18
  • 26