HOWTO: USERSIDE cloning: различия между версиями
Нет описания правки |
|||
Строка 1: | Строка 1: | ||
[[HOWTO:_USERSIDE_cloning|en]] | [[HOWTO:_Клонирование_USERSIDE|ru]] | [[HOWTO:_USERSIDE_cloning|en]] | [[HOWTO:_Клонирование_USERSIDE|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="ru_RU.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 | |||
* 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" "userside-stomp" "^userside-stomp:id-.*" "" "^userside-stomp:id-.*" | |||
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 | |||
* In version 3.16 and newer you will also need to recreate the venv for the poller microservice: | |||
sudo rm -rf /var/www/userside-copy/microservice/poller/venv | |||
cd /var/www/userside-copy/microservice/poller | |||
sudo -H python3 -m virtualenv -p /usr/bin/python3 venv | |||
sudo -H ./venv/bin/pip install --upgrade -r requirements.txt | |||
* Also from version 3.16 the supervisor configuration for kernel background processes and poller microservices will need to be copied: | |||
sudp 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/us-poller-microservice.conf /etc/supervisor/conf.d/us-copy-poller-microservice.conf | |||
sudo sed -i "s@us-poller-microservice@us-copy-poller-microservice@" "/etc/supervisor/conf.d/us-copy-poller-microservice.conf" | |||
sudo sed -i "s@/var/www/userside/@/var/www/userside-copy/@" "/etc/supervisor/conf.d/us-copy-poller-microservice.conf" | |||
sudo systemctl restart supervisor | |||
* it is now possible to open your copy in the browser. |
Версия от 15:23, 1 марта 2023
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="ru_RU.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
- 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" "userside-stomp" "^userside-stomp:id-.*" "" "^userside-stomp:id-.*"
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
- In version 3.16 and newer you will also need to recreate the venv for the poller microservice:
sudo rm -rf /var/www/userside-copy/microservice/poller/venv cd /var/www/userside-copy/microservice/poller sudo -H python3 -m virtualenv -p /usr/bin/python3 venv sudo -H ./venv/bin/pip install --upgrade -r requirements.txt
- Also from version 3.16 the supervisor configuration for kernel background processes and poller microservices will need to be copied:
sudp 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/us-poller-microservice.conf /etc/supervisor/conf.d/us-copy-poller-microservice.conf sudo sed -i "s@us-poller-microservice@us-copy-poller-microservice@" "/etc/supervisor/conf.d/us-copy-poller-microservice.conf" sudo sed -i "s@/var/www/userside/@/var/www/userside-copy/@" "/etc/supervisor/conf.d/us-copy-poller-microservice.conf"
sudo systemctl restart supervisor
- it is now possible to open your copy in the browser.