четверг, 30 декабря 2021 г.

Magento 2 How to throw report error page (500 error) for testing purpose

 The goal is to get a report page for testing purpose 

So, we have to break magento somehow.

The fast way is:

1. pub/media is symlink to media folder

2. rename real media folder to media.bk

3. open PLP and enjoy the error

var/report will be:

Directory \"\/mnt\/data\/www\/project\/releases\/pub\/media\" cannot be created Warning!mkdir(): File exists" ...

четверг, 16 сентября 2021 г.

Linux Bash check disk space

df --output=pcent / | tail -n +2 | tr -cd '0-9\n'

output available percent without header and symbol '%' - only number

#!/bin/bash

for mnt in / /var/log /var/www /mnt/shared; do

  chk_avail=`df --output=pcent $mnt | tail -n +2 | tr -cd '0-9\n'`

  flg=`echo $(( 100 - $chk_avail ))`

  if [ $flg -lt 15 ]; then

    echo 'Dataserver lack of free space, only '$flg' percent available in '$mnt' partition' | mail -s 'Dataserver lack of free space' alerts@gmail.com

  fi

done



пятница, 23 апреля 2021 г.

Magento 2 Multistore one domain

domain.com/store1

domain.com/store2

  1. Admin Panel: Stores/Settings/Stores (table store for checking code for MAGE_RUN_CODE)
    website: base, store: store1_code, store view: store1
    website: base, store: store2_code, store view: store2
  2. Admin Panel: Configuration/Web/URL Options/Add Store Code to Urls - Yes
  3. NGINX: 

    .php

        fastcgi_param  MAGE_RUN_TYPE    $MAGE_RUN_TYPE;

        fastcgi_param  MAGE_RUN_CODE    $MAGE_RUN_CODE;

    http

    map $request_uri $MAGE_RUN_CODE {

        ~^/store1 store1;

        ~^/store2 store2;

    }

    server
        set $MAGE_RUN_TYPE store;

воскресенье, 14 марта 2021 г.

среда, 24 февраля 2021 г.

grep with wildcard

 If you have a file with data and you need only words which starts with ABCD- and three numbers at the end. You can use it

 egrep -ow ABCD-... the_file

-o, --only-matching

 -w, --word-regexp         force PATTERN to match only whole words

... - three any numbers