Skip to content
Advertisement

I want to automate my angular build using pos-receive in background process

I want to automate my angular build using pos-receive and i want it to run in backgound process so I will not wait to finish the command.

I tried the following the following code on my post-receive but it doesn’t work.

post-receive

#!/bin/bash
git --work-tree=/var/www/my-sample-app.com --git-dir=/var/repo/my-sample-app.com.git checkout -f master
cd /var/www/my-sample-app.com
ng build --prod >/dev/null 2>&1 & 

I also tried to create a separate executable script on usr/local/bin directory like this

build-app-script

#!/bin/bash
cd /var/www/my-sample-app.com
mkdir test-dir
ng build --prod

then on my post-receive i change the code

ng build --prod >/dev/null 2>&1 & 

to

nohup /usr/local/bin/build-app-script &>/dev/null 2>&1 &

the script seems working because it create a test-dir but the ng-build –prod command is not executing

Any idea why is not working? or any suggestion. Thanks!

Advertisement

Answer

I think i figure out my problem, i have a vps server on digital ocean with 500mb of ram. So when i run the ng build –prod command the process get killed. I think because of the insuficient ram. Then after googling solutions i found this tutorial that will add an extra ram to your server and it works perfectly. Ref: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement