I have to restart my webserver every time I make a change to my .pm files so I am trying to set up a restart in the post-receive hook.
#!/bin/sh
GIT_WORK_TREE=/web git checkout -f
rap stop
sleep 5
rap start
When I restart manually, I have to go root and type rap stop/start. Right now I'm getting
remote: hooks/post-receive: line 3: rap: command not found
remote: hooks/post-receive: line 5: rap: command not found
when I make a push. I think permission are blocking me and I need some help to figure it out.
If you need those commands used as root, you could, as in "How to execute commands as root in git post-receive hook":
- create a separate script containing only the commands to run as root.
#!/bin/bash
sudo /full/path/to/rap stop
sudo /full/path/to/rap start
- in the post-receive script do:
#!/bin/bash
export GIT_WORK_TREE=/var/www/current/myapp/
set -x
echo "Checking out new files on production and restarting app"
echo $USER
git checkout -f
sudo /home/admin/restart-myapp
- And finally in the
visudo:
%sudo ALL=(ALL:ALL) ALL
admin ALL=(ALL) NOPASSWD: /home/admin/restart-myapp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With