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
1
  • I'm guessing Linux or unix like OS from your forward slashes. Commented Jan 27, 2018 at 18:33

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.