Answer the question
In order to leave comments, you need to log in
`
Is it possible to intercept the call of the program termination command in the terminal?
There is a script that launches several programs and ultimately remains access through pressing the ctrl + c combination only for the last launched program.
for example `cd hapi && npm run hapi & cd ../ & node scripts/start.js`
starts the frontend server and the backend server.
- When the program is terminated, only the frontend server
is terminated accordingly - is it possible to somehow intercept pressing ctrl + c or ctrl + z and, by calling the appropriate commands, terminate the work and the back end of the program?
Answer the question
In order to leave comments, you need to log in
Tin. Change to systemd.
vim /etc/systemd/system/backend.service
[Service]
ExecStart=/usr/bin/node /opt/backend/server.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=backend
User=root
Group=root
WorkingDirectory= /opt/backend
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start backend.service
Write two units for systemd and not do any costing, for example.
You can even run it through systemd-run if you try it once.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question