BackUp SQL DB in container
Asterisk
http://www.asterisk.ru/knowledgebase/Asterisk+config+extensions.conf
Call records:
https://drive.google.com/file/d/18gv-BN8GggjAu1zpQGbK1Y4_vJsnOg4u/view
https://www.youtube.com/watch?v=1ugmJDODYsI
Disable cron emails (solution)
This article lists three common methods to disable cron emails and another solution to send emails only when errors occur. Cron is a daemon that executes scheduled commands. More specifically, the software utility cron is a time-based job scheduler for Unix-like operating systems like Linux.
Table of Contents:
- Why Disable cron emails?
- Method 1: Redirecting Output to Null
- Method 2: Adjusting the MAILTO Variable
- Method 3: Using CRONDARGS for Advanced Control
- Method 4: Error-Only Notifications with Cronic
Cron’s automatic email feature is a double-edged sword. While it conveniently sends outputs of cron jobs via email, it can lead to an overwhelming influx of repetitive or duplicate messages. This can clutter your inbox, making it challenging to identify important emails.
To manage this, you might consider either reducing the frequency of these notifications or disabling them entirely. This approach helps streamline your email management, ensuring that only essential communications capture your attention, which is particularly beneficial in a busy IT environment.
Method 1: Redirecting Output to Null
We can disable cron emails by adding >/dev/null 2>&1 to the end of each cron job line. For example:
/dev/null = a device file location in Unix systems that discards any data written to it.
2>&1 = redirects stderr (standard errors) and stdout (standard output).
This results in both the Standard Error and Standard Out being redirected to /dev/null, rather than sent by email.
Method 2: Adjusting the MAILTO Variable
For cron, the default value of MAILTO is root. We can change the root value of the MAILTO variable via the /etc/crontab config file to "" (blank). Example:
Break down team silos, troubleshoot faster, and optimize at enterprise scale.
Get your free product brief
This disables cron daemon’s emails.
Method 3: Using CRONDARGS for Advanced Control
If you disable cron emails completely and something goes wrong, you will lose the output. You can get around this by setting CRONDARGS string. For example:
-s = forwards the output to system log.
-m off = disables cron emails.
On RHEL/Fedora, you can edit /etc/sysconfig/crond. So that it looks similar to:
For Debian/Ubuntu, you can edit using:
systemctl edit --full cron.service
Method 4: Error-Only Notifications with Cronic
Cronic is a small shell script for wrapping cron jobs so that cron will only send an email when an error has occurred. Cronic defines an error as any non-trace error output or a non-zero result code. Example usage:
terraform lock
It might be possible that you are in the middle of running terraform plan or terraform apply command but unfortunately, you ended up with the error - Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed.
Reason- Terraform has an internal validation that checks if there is a state lock already present then another process can not access the same resource with the same state
- Terraform allows you to have one process with one state lock.
- When more than one process tries to acquire the same state lock on the same resource then it might result in the Error locking state: Error acquiring the state lock: ConditionalCheckFailedException.
- Another possible reason is the
- Network outage - Because of the network outage there is a chance the previous terraform process might have terminated before it completion resulting in the error.
- incorrect AWS profile - In your project, you have multiple AWS profile but you are using an incorrect AWS profile which will also result in the same error.
How to fix it?
1) Kill task by id terraform force-unlock -force {ID error task}
2) Use -lock=false along with terraform plan - If the previous force-unlock command does not work then use the -lock=false command
3) kill terraform process- Well if none of the previous solutions works then I would recommend using kill -9 to terminate the process.
- Find the terraform Process ID using the command
ps aux | grep terraform - Kill the process using -
kill -9 <process_id>
GitLab - base structure
stages:
- PROD
- STAGE
- DEVelop
variables:
Helth_etalon: "hello world"
PROD-general:
environment:
name: brands
stage: PROD
tags:
- "brands"
when: manual #always
# except:
# changes:
# - "*.yml"
only:
- master
variables:
ENV_FILE: ".env"
HOSTDNS: "ksi.kiev.ua"
extends: .build-prod
.incrementbuildnumber:
before_script:
- echo "------------------ increment ---------------------------"
- echo "BUILDNumber_major == ${build_number_major}"
- echo ${CI_PIPELINE_ID}
- FullTagVersion="${build_number_major}.${CI_PIPELINE_ID}"
- echo "FullTagVersion ==== $FullTagVersion"
- export RATEBUILDVERSION=$FullTagVersion
- echo $RATEBUILDVERSION > $CI_PROJECT_DIR/bildver.txt
- echo $RATEBUILDVERSION
&& sed -i "s/version/$RATEBUILDVERSION/g" index.html
&& cat index.html
.build:
extends:
- .incrementbuildnumber
- .report
script:
- echo "----------------------- build task DEV ${HOSTDNS} -----------------------------------"
- hostip=$(curl ifconfig.me)
- echo "-------DEPLOY TO SERVER:----- $hostip ---------------------"
- docker-compose down && sleep 10
- docker system prune -af --filter "until=1h"
- rm -rf /home/services/app
- mkdir -p /home/services/app/
- mv ../trades /home/services/ && cd /home/services/app
- mkdir -p /home/services/app/infra/trades/log/nginx
- docker-compose build app-app
- docker-compose up -d app-app
.report:
after_script:
- echo "-----------------after_script --- report ----------------"
- VERSION=$(cat $CI_PROJECT_DIR/bildver.txt)
- if [[ ${HOSTDNS} != "ksi.kiev.ua" ]]; then ssh $RUNNER_GITLAB@$IP_SERVER "export PROJECT=${PROJECT} && echo $PROJECT
&& export PROJECT_PATH=${PROJECT_PATH} && echo $PROJECT_PATH
&& export BRANCH_PATH=${BRANCH_PATH}
&& export CI_JOB_STAGE=${CI_JOB_STAGE}
&& export GITLAB_USER_NAME=${GITLAB_USER_NAME}
&& export CI_PIPELINE_ID=$(echo ${CI_PIPELINE_ID})
&& export VERSION=$(echo $VERSION)
&& export TYPECODE="PHP"
&& chmod +x $PATH_CREDENTIALS/check_logs_svc.sh
Cat Dockerfile:
FROM node:12.4-alpine
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY ./ ./
RUN npm install
COPY . .
Cat docker-compose.yml
version: "3.9"
services:
trade-app:
image: trade:PROD-${RATEBUILDVERSION}
build:
context: .
dockerfile: ./Dockerfile-prod
# ports:
# - "8080:8080"
entrypoint: sh -c "npm install && npm run prod && rm -rf distcopy/* && cp -r dist/* distcopy/ && sleep 20"
volumes:
- ../www/:/usr/src/app/distcopy
extra_hosts:
- "trades.brocrm.com:127.0.0.1"
container_name: trade-app
networks:
- trade-net
- crm_backend
networks:
trade-net:
driver: bridge
ipam:
config:
- subnet: 192.168.70.0/24
gateway: 192.168.70.1
crm_backend:
name: crm_backend
Cat check_logs_svc.sh:
#!/bin/bash
#in CI/CD pipelnes needed declarate variables
#export PROJECT=gaming
#export PROJECT_PATH=report
echo $PROJECT
echo $PROJECT_PATH
echo $TYPECODE
##########################################
svc=$(docker service ls --format "{{.Name}}" | grep $PROJECT_PATH | grep $PROJECT) && echo $svc
echo "============================================================================================"
sleep 3s
#timeout 10 docker service logs --raw --since 2m -f --no-trunc $svc
logresult=$(timeout -v 5 docker service logs --raw --since 2m -f --no-trunc $svc 2>&1)
timeout -v 5 docker service logs --raw --since 2m -f --no-trunc $svc 2>&1
echo $logresult
echo "======================================================================================"
if [[ $(echo $logresult | grep 'error') ]]; then
status="HAS error!!!!!"
echo "====================$svc deploy $status"
else
status="NO error"
echo "====================$svc deploy $status"; fi
echo "================================= end validation ==================================="
if [[ $BRANCH_PATH == "master" ]]; then echo "--------master";
elif [[ $BRANCH_PATH == "develop" ]]; then echo "--------develop";
elif [[ $BRANCH_PATH == "stage" ]]; then echo "--------stage";
else echo "other"; fi
echo "======================================================================================="
echo "TEXT FOR TELEGRAM CURL Deploy NODE.js $PROJECT $PROJECT_PATH from $BRANCH_PATH! job $CI_JOB_STAGE By $GITLAB_USER_NAME n=$CI_PIPELINE_ID $VERSION $status "
curl -s -X POST https://api.telegram.org/bot571ххххххх:ххххххххххххххххххххххххх-o8/sendMessage -d chat_id=-ххххххххх -d text="Deploy $TYPECODE $PROJECT $PROJECT_PATH from $BRANCH_PATH! job $CI_JOB_STAGE By $GITLAB_USER_NAME n=$CI_PIPELINE_ID $VERSION $status "