Why is process not exiting and how to get it to exit
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a server I want to run (on one HTTP port), and then another script (which runs (temporarily) on another port).
I'm using a pipe in order to let these run concurrently, and brackets to group the commands such that sleep occurs first (the second script accesses the server started in the first, so there needs to be some time for the first to be set up).
It works fine, with the server getting started and the sleep and test file executing correctly thereafter, but the terminal process does not exit automatically after the test as it does when just running the script.
npm run start-json-server | sleep 1; node './test/index-cjs.js' ;
What do I need to do to allow a natural exit (preferably without going through the trouble of finding the process and killing it)?
Update: I realized it was still running (duh) because the first script, as a server, doesn't terminate... But is there a way I can get it to terminate, again, preferably without finding its PID?
shell npm
New contributor
add a comment |Â
up vote
0
down vote
favorite
I have a server I want to run (on one HTTP port), and then another script (which runs (temporarily) on another port).
I'm using a pipe in order to let these run concurrently, and brackets to group the commands such that sleep occurs first (the second script accesses the server started in the first, so there needs to be some time for the first to be set up).
It works fine, with the server getting started and the sleep and test file executing correctly thereafter, but the terminal process does not exit automatically after the test as it does when just running the script.
npm run start-json-server | sleep 1; node './test/index-cjs.js' ;
What do I need to do to allow a natural exit (preferably without going through the trouble of finding the process and killing it)?
Update: I realized it was still running (duh) because the first script, as a server, doesn't terminate... But is there a way I can get it to terminate, again, preferably without finding its PID?
shell npm
New contributor
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
Thestart-json-server
one--once the node test script is finished.
â Brett Zamir
Oct 1 at 6:14
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a server I want to run (on one HTTP port), and then another script (which runs (temporarily) on another port).
I'm using a pipe in order to let these run concurrently, and brackets to group the commands such that sleep occurs first (the second script accesses the server started in the first, so there needs to be some time for the first to be set up).
It works fine, with the server getting started and the sleep and test file executing correctly thereafter, but the terminal process does not exit automatically after the test as it does when just running the script.
npm run start-json-server | sleep 1; node './test/index-cjs.js' ;
What do I need to do to allow a natural exit (preferably without going through the trouble of finding the process and killing it)?
Update: I realized it was still running (duh) because the first script, as a server, doesn't terminate... But is there a way I can get it to terminate, again, preferably without finding its PID?
shell npm
New contributor
I have a server I want to run (on one HTTP port), and then another script (which runs (temporarily) on another port).
I'm using a pipe in order to let these run concurrently, and brackets to group the commands such that sleep occurs first (the second script accesses the server started in the first, so there needs to be some time for the first to be set up).
It works fine, with the server getting started and the sleep and test file executing correctly thereafter, but the terminal process does not exit automatically after the test as it does when just running the script.
npm run start-json-server | sleep 1; node './test/index-cjs.js' ;
What do I need to do to allow a natural exit (preferably without going through the trouble of finding the process and killing it)?
Update: I realized it was still running (duh) because the first script, as a server, doesn't terminate... But is there a way I can get it to terminate, again, preferably without finding its PID?
shell npm
shell npm
New contributor
New contributor
edited Oct 1 at 6:06
New contributor
asked Oct 1 at 5:57
Brett Zamir
993
993
New contributor
New contributor
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
Thestart-json-server
one--once the node test script is finished.
â Brett Zamir
Oct 1 at 6:14
add a comment |Â
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
Thestart-json-server
one--once the node test script is finished.
â Brett Zamir
Oct 1 at 6:14
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
The
start-json-server
one--once the node test script is finished.â Brett Zamir
Oct 1 at 6:14
The
start-json-server
one--once the node test script is finished.â Brett Zamir
Oct 1 at 6:14
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
A pipe is not used for starting concurrent processes. It does do that, but it's mainly used for setting up a data stream between two stages of a pipeline.
Instead of your pipeline, use
npm run start-json-server &
server_pid="$!"
sleep 1
node ./test/index-cjs.js
kill "$server_pid"
This would start the first command in the background. There would then be a one second delay before the second command is started. When the second command finishes, the first command is killed.
The PID of the most recently started background process (a process started by using &
at the end of it) is available as "$!"
, and here we use that fact to keep track of the PIDs of the first command.
add a comment |Â
up vote
-1
down vote
I went ahead with this in getting the process:
npm run start-json-server | grep '[n]ode test/server'
However, if someone has a cleaner answer, please let me know.
New contributor
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
A pipe is not used for starting concurrent processes. It does do that, but it's mainly used for setting up a data stream between two stages of a pipeline.
Instead of your pipeline, use
npm run start-json-server &
server_pid="$!"
sleep 1
node ./test/index-cjs.js
kill "$server_pid"
This would start the first command in the background. There would then be a one second delay before the second command is started. When the second command finishes, the first command is killed.
The PID of the most recently started background process (a process started by using &
at the end of it) is available as "$!"
, and here we use that fact to keep track of the PIDs of the first command.
add a comment |Â
up vote
0
down vote
A pipe is not used for starting concurrent processes. It does do that, but it's mainly used for setting up a data stream between two stages of a pipeline.
Instead of your pipeline, use
npm run start-json-server &
server_pid="$!"
sleep 1
node ./test/index-cjs.js
kill "$server_pid"
This would start the first command in the background. There would then be a one second delay before the second command is started. When the second command finishes, the first command is killed.
The PID of the most recently started background process (a process started by using &
at the end of it) is available as "$!"
, and here we use that fact to keep track of the PIDs of the first command.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
A pipe is not used for starting concurrent processes. It does do that, but it's mainly used for setting up a data stream between two stages of a pipeline.
Instead of your pipeline, use
npm run start-json-server &
server_pid="$!"
sleep 1
node ./test/index-cjs.js
kill "$server_pid"
This would start the first command in the background. There would then be a one second delay before the second command is started. When the second command finishes, the first command is killed.
The PID of the most recently started background process (a process started by using &
at the end of it) is available as "$!"
, and here we use that fact to keep track of the PIDs of the first command.
A pipe is not used for starting concurrent processes. It does do that, but it's mainly used for setting up a data stream between two stages of a pipeline.
Instead of your pipeline, use
npm run start-json-server &
server_pid="$!"
sleep 1
node ./test/index-cjs.js
kill "$server_pid"
This would start the first command in the background. There would then be a one second delay before the second command is started. When the second command finishes, the first command is killed.
The PID of the most recently started background process (a process started by using &
at the end of it) is available as "$!"
, and here we use that fact to keep track of the PIDs of the first command.
edited Oct 1 at 7:27
answered Oct 1 at 7:14
Kusalananda
108k14210333
108k14210333
add a comment |Â
add a comment |Â
up vote
-1
down vote
I went ahead with this in getting the process:
npm run start-json-server | grep '[n]ode test/server'
However, if someone has a cleaner answer, please let me know.
New contributor
add a comment |Â
up vote
-1
down vote
I went ahead with this in getting the process:
npm run start-json-server | grep '[n]ode test/server'
However, if someone has a cleaner answer, please let me know.
New contributor
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
I went ahead with this in getting the process:
npm run start-json-server | grep '[n]ode test/server'
However, if someone has a cleaner answer, please let me know.
New contributor
I went ahead with this in getting the process:
npm run start-json-server | grep '[n]ode test/server'
However, if someone has a cleaner answer, please let me know.
New contributor
New contributor
answered Oct 1 at 7:00
Brett Zamir
993
993
New contributor
New contributor
add a comment |Â
add a comment |Â
Brett Zamir is a new contributor. Be nice, and check out our Code of Conduct.
Brett Zamir is a new contributor. Be nice, and check out our Code of Conduct.
Brett Zamir is a new contributor. Be nice, and check out our Code of Conduct.
Brett Zamir is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472501%2fwhy-is-process-not-exiting-and-how-to-get-it-to-exit%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Which terminal process you want to exit automatically?
â ploth
Oct 1 at 6:12
The
start-json-server
one--once the node test script is finished.â Brett Zamir
Oct 1 at 6:14