Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
559 views
in Technique[技术] by (71.8m points)

node.js - How to shut down a node server with a shell script?

The context of this question is that I am setting up a CI/CD pipeline in AWS. I'm currently at the stage where I am creating the appspec.yml file which instructs the AWS robots on where to put my files from my new build onto my EC2 instance, as well as a list of .sh files with bash commands to stop the server, install dependencies and start the server again.

Well right off the bat I have hit a wall here. The method to shut down a node server is ctrl+c. However I have no idea how to successfully put that into bash script. And considering how many people have CI/CD pipelines setup with node servers, i'm shocked that I haven't been able to find a sample script file for this already. Does anyone have any resources on this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the command kill (or it's variations like pkill) to send a signal to the server process and shut it down.

kill requires the pid of the process whereas pkill requires the name of the process


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...