使用sudoer在post-receive-git-hook中重新启动服务器

使用sudoer在post-receive-git-hook中重新启动服务器,git,webserver,hook,git-post-receive,Git,Webserver,Hook,Git Post Receive,每次更改.pm文件时,我都必须重新启动Web服务器,因此我正在尝试在post接收挂钩中设置重新启动 #!/bin/sh GIT_WORK_TREE=/web git checkout -f rap stop sleep 5 rap start 当我手动重新启动时,我必须转到root并键入rap stop/start。现在我有点累了 remote: hooks/post-receive: line 3: rap: command not found remote: hooks/post-rec

每次更改.pm文件时,我都必须重新启动Web服务器,因此我正在尝试在post接收挂钩中设置重新启动

#!/bin/sh
GIT_WORK_TREE=/web git checkout -f
rap stop
sleep 5
rap start
当我手动重新启动时,我必须转到root并键入rap stop/start。现在我有点累了

remote: hooks/post-receive: line 3: rap: command not found 
remote: hooks/post-receive: line 5: rap: command not found

当我推的时候。我想是许可阻碍了我,我需要一些帮助来解决这个问题

如果需要将这些命令用作root,可以,如“”:

  • 创建一个单独的脚本,其中只包含要作为root用户运行的命令
  • 在post接收脚本中,执行以下操作:
  • 最后在
    visudo
    中:
    #!/bin/bash
    sudo /full/path/to/rap stop
    sudo /full/path/to/rap start
    #!/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
    %sudo   ALL=(ALL:ALL) ALL
    admin   ALL=(ALL) NOPASSWD: /home/admin/restart-myapp