Linked Questions

Popular Questions

I have a shell script to auto build and deploy docker in Centos. I create webserver by ExpressJs and make server-sent event API.

How to know "end" event when executing shell script ? Do I need to change my shell script ? This is my code backend API and frontend

`getData = (flag) => {
    var elem = document.getElementById("myBar");
    var width = 0;
    var source = new EventSource('/data');
    if (flag) {
        source.addEventListener('message', (e) => {
            var data = e.lastEventId == -1 ? "Done" : JSON.parse(e.data);
            var clock = setInterval(() => {
                if (width >= 100) {
                    clearInterval(clock);
                } else {
                    width++;
                    elem.style.width = width + '%';
                }
            }, (Date.now() - e.timeStamp));
}`

And my script

 !/bin/bash 
#..........
nodeId=$(ps aux | grep node | awk '{if($13=="server.js") print $2}')
if [ -z $nodeId ]; then
    echo "Not found"
else
    echo "Kill process"
    kill -9 $nodeId 
fi
    echo "Finish"
npm install 
nohup npm run start server.js  &  
exit 0

Related Questions