Я пытаюсь настроить webhook в моей системе непрерывной интеграции, чтобы мой сервер развертывания мог автоматически развертываться, когда я что-то нажимаю на свой Git.
Я сделал это с помощью сценария оболочки, который я сделал доступнымкак CGI-скрипт с Apache.
Это работает нормально, единственная проблема в том, что стандартный вывод из моего скрипта перенаправляется в журнал ошибок вместо ответа HTTP ...
Мой скриптв пользовательской папке, и у меня есть такая символическая ссылка в /var/www/cgi-bin
:
lrwxrwxrwx 1 root root 21 Nov 29 20:52 deploy -> /srv/myapp/deploy.sh
Сценарий развертывания содержит:
#!/bin/bash
base_path="/srv/myapp"
echo "Content-type: text/plain"
echo ""
cd $base_path
sudo docker-compose stop
sudo docker-compose pull
sudo docker-compose up -d
sudo docker system prune -f
exit 0
Мой файл sudoers содержит:
apache ALL = NOPASSWD: /usr/bin/docker-compose
И журнал ошибок содержит:
[Sun Dec 02 11:01:31.748772 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Stopping myapp_http_1_a3ca0bdbd648 ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:31.749003 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Stopping myapp_client_1_cb16b60351f0 ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:31.749151 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Stopping myapp_server_1_6c148be61c2c ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:31.749276 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Stopping myapp_database_1_2959978817cd ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:32.532484 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[4A\x1b[2K\rStopping myapp_http_1_a3ca0bdbd648 ... \x1b[32mdone\x1b[0m\r\x1b[4B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:42.705754 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[3A\x1b[2K\rStopping myapp_client_1_cb16b60351f0 ... \x1b[32mdone\x1b[0m\r\x1b[3B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:52.911671 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[2A\x1b[2K\rStopping myapp_server_1_6c148be61c2c ... \x1b[32mdone\x1b[0m\r\x1b[2B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.105109 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rStopping myapp_database_1_2959978817cd ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.645366 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Pulling database ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.645577 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Pulling server ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.645703 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Pulling client ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.645808 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Pulling http ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.931960 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[2A\x1b[2K\rPulling client ... pulling from myaccount/myapp\r\x1b[2B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.932480 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[2A\x1b[2K\rPulling client ... digest: sha256:06202040641b409706...\r\x1b[2B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.932865 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[2A\x1b[2K\rPulling client ... status: image is up to date for g...\r\x1b[2B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.933561 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[2A\x1b[2K\rPulling client ... \x1b[32mdone\x1b[0m\r\x1b[2B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.955566 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[4A\x1b[2K\rPulling database ... pulling from myaccount/myapp\r\x1b[4B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.955944 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[4A\x1b[2K\rPulling database ... digest: sha256:c63765a78a26f72ec7...\r\x1b[4B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.956375 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[4A\x1b[2K\rPulling database ... status: image is up to date for g...\r\x1b[4B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.956925 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[4A\x1b[2K\rPulling database ... \x1b[32mdone\x1b[0m\r\x1b[4B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.964085 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rPulling http ... pulling from myaccount/myapp\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.964472 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rPulling http ... digest: sha256:4bfc963090f942cba9...\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.964782 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rPulling http ... status: image is up to date for g...\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:53.965265 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rPulling http ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:54.071190 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[3A\x1b[2K\rPulling server ... pulling from myaccount/myapp\r\x1b[3B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:54.071609 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[3A\x1b[2K\rPulling server ... digest: sha256:15dcd5ebba6a815342...\r\x1b[3B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:54.071918 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[3A\x1b[2K\rPulling server ... status: image is up to date for g...\r\x1b[3B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:54.073097 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[3A\x1b[2K\rPulling server ... \x1b[32mdone\x1b[0m\r\x1b[3B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:54.658070 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Starting myapp_database_1_2959978817cd ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:55.416923 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rStarting myapp_database_1_2959978817cd ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:55.417759 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Starting myapp_server_1_6c148be61c2c ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:55.824527 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rStarting myapp_server_1_6c148be61c2c ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:55.825299 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Starting myapp_client_1_cb16b60351f0 ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:56.497106 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rStarting myapp_client_1_cb16b60351f0 ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:56.499781 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: Starting myapp_http_1_a3ca0bdbd648 ... \r: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:57.360969 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: \x1b[1A\x1b[2K\rStarting myapp_http_1_a3ca0bdbd648 ... \x1b[32mdone\x1b[0m\r\x1b[1B: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:57.443070 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: sudo: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:57.443239 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: : : /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:57.443360 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: no tty present and no askpass program specified: /var/www/cgi-bin/deploy
[Sun Dec 02 11:01:57.443434 2018] [cgi:error] [pid 25813] [client 12.34.56.78:51316] AH01215: : /var/www/cgi-bin/deploy
Ответ HTTP полностью пуст.