- Set up an AWS instance and download the corresponding private key, here we call it
aws.pem mv aws.pem ~/.sshchmod 400 ~/.ssh/aws.pemeval `ssh-agent -s`for startingssh-agentssh-add ~/.ssh/aws.pemto add the private key- Connect by
ssh ubuntu@....aws.net - (Optional) Use
no-ipservice to use DNS to connect instead - (Optional) Add step 4 and 5 to
~/.bashrcor~/.zshrcto load keys upon booting
mkdir my_project.git && cd my_project.gitgit init --baremkdir ../my_projectcd hooks && touch post-receive- Add the followings into
post-receive#!bin/sh GIT_WORK_TREE=~/my_project git checkout -f # Can add more scripts to run in aws after receiving git push
chmod +x post-receive
git remote add aws ubuntu@....aws.netgit config --global remote.aws.receivepack "git receive-pack"- Push by
git push aws
- Install
pm2bynpm i -g pm2 - Append the following to
post-receivenpm install \ && npm run build \ && (pm2 delete 'my-app' || true) \ && pm2 start npm --name 'my-app' -- start
- (Optional) View real-time log from local by
ssh ubuntu@....aws.net "tail -f ~/my_project/log.log" | ccze(cczeis installed byapt).
{
"apiKey": ,
"config": [{
"start": "2018-11-16",
"end": "2018-11-20",
"per": 60
}
]
}