HOWTO: USERSIDE cloning: различия между версиями

Материал из WiKi - UserSide
([IronBot] Sync EN/UK localization from RU)
([IronBot] Sync localization from RU)
 
Строка 13: Строка 13:
  sudo sed -i "s@/var/www/userside/userside3@/var/www/userside-copy/userside3@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo sed -i "s@/var/www/userside/userside3@/var/www/userside-copy/userside3@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo sed -i "s@/var/log/nginx/userside@/var/log/nginx/userside-copy@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo sed -i "s@/var/log/nginx/userside@/var/log/nginx/userside-copy@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo sed -i "s@старое.доменное.имя@новое.доменное.имя@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo sed -i "s@old.domain.name@new.domain.name@" "/etc/nginx/conf.d/userside-copy.conf"
  sudo systemctl reload nginx
  sudo systemctl reload nginx


* Copy the database (or create a new database and restore it from a backup):
* Copy the database (or create a new database and restore it from a backup):
  sudo -u postgres createdb -e --encoding="UTF-8" --locale="ru_RU.UTF-8" --owner=userside --template=userside userside_copy
  sudo -u postgres createdb -e --encoding="UTF-8" --locale="uk_UA.UTF-8" --owner=userside --template=userside userside_copy
If you are copying the database to another server, you will need to create a role, necessarily the same as in the dump, before restoring it:
If you are copying the database to another server, you will need to create a role, necessarily the same as in the dump, before restoring it:
  sudo -u postgres createuser userside -P
  sudo -u postgres createuser userside -P
Строка 25: Строка 25:
  US_DB_DSN=pgsql:host=localhost;dbname=userside_copy;port=5432
  US_DB_DSN=pgsql:host=localhost;dbname=userside_copy;port=5432
  US_REDIS_DB=1
  US_REDIS_DB=1
* Clear the Redis database you plan to use:
redis-cli -n 1 -a redis_password FLUSHDB


* For versions up to 3.13, edit the database connection parameters in common/config/db.php and the URL in userside3/main/config/config.php
* For versions up to 3.13, edit the database connection parameters in common/config/db.php and the URL in userside3/main/config/config.php
Строка 37: Строка 40:
Now change the variable US_AMQP_DSN of the .env file this way:
Now change the variable US_AMQP_DSN of the .env file this way:
  US_AMQP_DSN=amqp://userside:yourpassword@127.0.0.1:5672/copy
  US_AMQP_DSN=amqp://userside:yourpassword@127.0.0.1:5672/copy
* Repair the copy with the installer (starting with version 3.19):
sudo -u www-data ./installer repair
For earlier versions:
sudo -u www-data php userside_install.phar repair


* In version 3.16 and newer you will also need to recreate the venv for the poller microservice:
* In version 3.16 and newer you will also need to recreate the venv for the poller microservice:
  cd /var/www/userside-copy/microservice/poller
  cd /var/www/userside-copy/microservice/poller
  sudo rm -rf venv
  sudo rm -rf venv
  sudo -H python3 -m venv venv
  sudo -u www-data python3 -m venv venv
  sudo -H venv/bin/pip install --upgrade -r requirements.txt
  sudo -u www-data venv/bin/pip install --upgrade -r requirements.txt


* Also starting with version 3.16 you will need to copy the supervisor configuration for the kernel background processes and the poller microservice. Also note that before version 3.18 the usm_poller.conf file was called us-poller-microservice.conf:
* Also starting with version 3.16 you will need to copy the supervisor configuration for the kernel background processes and the poller microservice. Also note that before version 3.18 the usm_poller.conf file was called us-poller-microservice.conf:

Текущая версия от 14:51, 25 сентября 2026

en | uk | ru

Copy of system for testing or research

If you need to make a copy of the system to try out the new version before the actual upgrade, or to do anything else, there are a few simple steps to follow:

  • copy the application files
cd /var/www/
sudo cp -r userside userside-copy
  • configure the web server to work with the copy - copy the configuration file, edit and re-read the nginx configuration:
sudo cp /etc/nginx/conf.d/userside.conf /etc/nginx/conf.d/userside-copy.conf
sudo sed -i "s@/var/www/userside/userside3@/var/www/userside-copy/userside3@" "/etc/nginx/conf.d/userside-copy.conf"
sudo sed -i "s@/var/log/nginx/userside@/var/log/nginx/userside-copy@" "/etc/nginx/conf.d/userside-copy.conf"
sudo sed -i "s@old.domain.name@new.domain.name@" "/etc/nginx/conf.d/userside-copy.conf"
sudo systemctl reload nginx
  • Copy the database (or create a new database and restore it from a backup):
sudo -u postgres createdb -e --encoding="UTF-8" --locale="uk_UA.UTF-8" --owner=userside --template=userside userside_copy

If you are copying the database to another server, you will need to create a role, necessarily the same as in the dump, before restoring it:

sudo -u postgres createuser userside -P
  • In version 3.13 and newer, go to the directory with the new copy, edit the environment variables in the .env file so that they work with the new database and with the other (free) redis database (in the main installation you probably have the redis database number 0; you can use the other 15 available by default). Variables are responsible for this:
US_URL=http://new.domain.name
US_DB_DSN=pgsql:host=localhost;dbname=userside_copy;port=5432
US_REDIS_DB=1
  • Clear the Redis database you plan to use:
redis-cli -n 1 -a redis_password FLUSHDB
  • For versions up to 3.13, edit the database connection parameters in common/config/db.php and the URL in userside3/main/config/config.php
  • In version 3.16 and newer you need to create an additional vhost for RabbitMQ, and then specify it in the .env file for the US_AMQP_DSN variable. The example below uses copy as the name of the new vhost (change to something more convenient for you if necessary). First run the command that creates the vhost, then add permissions for users within that vhost:
sudo rabbitmqctl add_vhost copy
sudo rabbitmqctl set_permissions -p "copy" "admin" ".*" ".*" ".*"
sudo rabbitmqctl set_permissions -p "copy" "userside" ".*" ".*" ".*"
sudo rabbitmqctl set_permissions -p "copy" "websock-user" "^erp-stomp:id-.*" "" "^erp-stomp:id-.*"
sudo rabbitmqctl --vhost copy set_user_tags "userside" "monitoring"

Now change the variable US_AMQP_DSN of the .env file this way:

US_AMQP_DSN=amqp://userside:yourpassword@127.0.0.1:5672/copy
  • Repair the copy with the installer (starting with version 3.19):
sudo -u www-data ./installer repair

For earlier versions:

sudo -u www-data php userside_install.phar repair
  • In version 3.16 and newer you will also need to recreate the venv for the poller microservice:
cd /var/www/userside-copy/microservice/poller
sudo rm -rf venv
sudo -u www-data python3 -m venv venv
sudo -u www-data venv/bin/pip install --upgrade -r requirements.txt
  • Also starting with version 3.16 you will need to copy the supervisor configuration for the kernel background processes and the poller microservice. Also note that before version 3.18 the usm_poller.conf file was called us-poller-microservice.conf:
sudo cp /etc/supervisor/conf.d/us-core-worker.conf /etc/supervisor/conf.d/us-copy-core-worker.conf
sudo sed -i "s@us-core-worker@us-copy-core-worker@" "/etc/supervisor/conf.d/us-copy-core-worker.conf"
sudo sed -i "s@/var/www/userside/@/var/www/userside-copy/@" "/etc/supervisor/conf.d/us-copy-core-worker.conf"
sudo cp /etc/supervisor/conf.d/usm_poller.conf /etc/supervisor/conf.d/usm_poller_copy.conf
sudo sed -i "s@usm_poller@usm_poller_copy@" "/etc/supervisor/conf.d/usm_poller_copy.conf"
sudo sed -i "s@/var/www/userside/@/var/www/userside-copy/@" "/etc/supervisor/conf.d/usm_poller_copy.conf"
sudo systemctl restart supervisor
  • it is now possible to open your copy in the browser.