среда, 31 октября 2018 г.

Linux Mariadb Can't start server: Bind on TCP/IP port. Got error: 98: Address already in use

Если не запускается mariadb с такой ошибкой, то проверить процессы, которые забиндили этот адрес командой:

lsof -i TCP:3306

Убить kill и стартовать mariadb

Gitlab-ci веб-интерфейс не отображает коммиты

Через gitlab log коммиты в v1.2.3 branch видно, через веб-интерфейс для этого branch коммитов нет с определенной даты.
Причиной оказался tag v1.2.3 созданный после той даты. После его удаления коммиты стали отображаться в веб-интерфейсе.

вторник, 30 октября 2018 г.

Linux Clear cache after site release

Проект Symphony, Nginx
Используется opcache
Как очистить cache, чтобы сайт корректно отображался после релиза.

Symphony
export APP_ENV=prod && php bin/console cache:clear
chown -R user:www-data user
opcache
php /usr/local/bin/cachetool.phar opcache:reset --fcgi=/dev/shm/php-user.sock --tmp-dir=/tmp
Nginx
очистить cache на стороне клиента
добавить в конфиг сервера
server
{
...
expires 10m
...
}

Gitlab-ci runner file remote: Access denied fatal: unable to access The requested URL returned error: 403

Resolving
Проект с галочкой private, тот кто делал merge с правами админа, но не состоял в группе проекта. В pipeline имели такую ошибку. После добавления в группу и retry все job из pipeline выполнились без вмешательства.

пятница, 26 октября 2018 г.

NGINX alias

Нужно отдавать png файлы из папки email подпапок folder1 folder2 etc на сайте domain.tld/email/folder/img.png
Использую alias
    location ~ ^/email/(.+\.(?:gif|jpe?g|png))$ {
        alias /home/www/email/$1;
    }

четверг, 25 октября 2018 г.

NVM version "N/A -> N/A" is not yet installed

Как избежать сообщения при запуске node
N/A: version "N/A -> N/A" is not yet installed. You need to run "nvm install N/A" to install it before using it.
Это мешает в ansible playbooks так как определяется как ошибка

Решение: изменить алиас
например
nvm alias default 8

среда, 24 октября 2018 г.

Gitlab-CI add gitlab-runner

1) Install
I need a version
apt-get install gitlab-runner=11.1.0

2) Register runner
It is located on this page http://take.ms/1u9oJ
Take address and token from here http://take.ms/3ypc0
Run
gitlab-runner register
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.domain.org/
Please enter the gitlab-ci token for this runner:
t6jJhKgcxxWjMvmZBddM
Please enter the gitlab-ci description for this runner:
[SERVERNAME]: project_name
Please enter the gitlab-ci tags for this runner (comma separated):
project_name
Registering runner... succeeded                     runner=t6jJhKgc
Please enter the executor: docker, docker-ssh, docker+machine, kubernetes, parallels, shell, ssh, virtualbox, docker-ssh+machine:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!


вторник, 16 октября 2018 г.

Linux bash сравнить даты файлов

Это ситуация, когда на одном https домене много IP. Обновляем на одном, потом rsync раскладываем по остальным и обновляем в случае изменения даты.

old=`/usr/bin/stat -c %Y /etc/letsencrypt/live/www.site/privkey.pem`
new=`/usr/bin/stat -c %Y /home/letsencrpt/etc/letsencrypt/live/www.site/privkey.pem`
difference=`expr "$new" - "$old"`

#checking the difference whether is number
if ! [[ "$difference" =~ ^-?[0-9]+$ ]]; then
      logging "Something was wrong with privkey.pem file, the script was stopped with error"
      rm /home/letsencrpt/letsencrypt.tar
      exit 1
fi

if [[ $difference -gt 0 ]]; then
      logging "Updating certs..."
      logging "Old creating date is $old, new creating date is $new"
      /bin/tar xvpf /home/letsencrpt/letsencrypt.tar -C /
fi

понедельник, 15 октября 2018 г.

Certbot auto renew

Где добавлять renew?
1) manual https://certbot.eff.org/docs/using.html?highlight=renew#renewing-certificates
    By default, the following locations are searched:
    /etc/letsencrypt/cli.ini
добавляем в этот файл
renew-hook = /usr/local/bin/renew.sh

в /usr/local/bin/renew.sh файл добавляем
#!/bin/sh
/bin/systemctl reload nginx

Проверяем в /var/log/letsencrypt

2) Если обновляется через systemd, то смотрим:

/lib/systemd/system/certbot.timer
и добавляем там
 --renew-hook "/bin/systemctl reload nginx"