mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-02 00:53:22 +02:00
Improved Message Broker stability
This commit is contained in:
parent
f6752b0d26
commit
82c8b27f69
7 changed files with 502 additions and 186 deletions
|
@ -113,12 +113,10 @@ For establishing your own mail server, both [Mox](https://github.com/mjl-/mox) a
|
|||
To run the Message Broker, execute the following commands:
|
||||
|
||||
```bash
|
||||
/usr/bin/php /opt/registry/automation/msg_producer.php &
|
||||
/usr/bin/php /opt/registry/automation/msg_worker.php &
|
||||
systemctl start msg_producer
|
||||
systemctl start msg_worker
|
||||
```
|
||||
|
||||
This will start the system and place it in the background, allowing it to run independently of your current terminal session.
|
||||
|
||||
#### 1.4.4. Setting Up an Audit Trail Database for Namingo
|
||||
|
||||
To create an audit trail database for Namingo, start by editing the configuration file located at `/opt/registry/automation/audit.json` with the correct database details. This includes specifying the database connection parameters such as host, username, and password. Once your configuration is set up, run the command:
|
||||
|
|
|
@ -455,7 +455,14 @@ EOF
|
|||
cp /opt/registry/docs/das.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable das.service
|
||||
|
||||
|
||||
echo "Installing Message Broker."
|
||||
cp /opt/registry/docs/msg_producer.service /etc/systemd/system/
|
||||
cp /opt/registry/docs/msg_worker.service /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable msg_producer
|
||||
systemctl enable msg_worker
|
||||
|
||||
echo "Configuring control panel admin."
|
||||
sed -i "s|\$email = 'admin@example.com';|\$email = '$PANEL_EMAIL';|g" /var/www/cp/bin/create_admin_user.php
|
||||
sed -i "s|\$newPW = 'admin_password';|\$newPW = '$PANEL_PASSWORD';|g" /var/www/cp/bin/create_admin_user.php
|
||||
|
|
22
docs/msg_producer.service
Normal file
22
docs/msg_producer.service
Normal file
|
@ -0,0 +1,22 @@
|
|||
[Unit]
|
||||
Description=Message Producer Service
|
||||
After=network.target redis.service
|
||||
Requires=redis.service
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=root
|
||||
Group=root
|
||||
Restart=on-failure
|
||||
ExecStart=/usr/bin/php /opt/registry/automation/msg_producer.php
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStop=/bin/kill -INT $MAINPID
|
||||
WorkingDirectory=/opt/registry/automation
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=msg_producer
|
||||
PIDFile=/var/run/msg_producer.pid
|
||||
LimitNOFILE=100000
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
19
docs/msg_worker.service
Normal file
19
docs/msg_worker.service
Normal file
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=Message Worker Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
Restart=on-failure
|
||||
ExecStart=/usr/bin/php /opt/registry/automation/msg_worker.php
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStop=/bin/kill -INT $MAINPID
|
||||
WorkingDirectory=/opt/registry/automation
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=msg_worker
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
137
docs/update1013.sh
Normal file
137
docs/update1013.sh
Normal file
|
@ -0,0 +1,137 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Prompt the user for confirmation
|
||||
echo "This will update Namingo Registry from v1.0.12 to v1.0.13."
|
||||
echo "Make sure you have a backup of the database, /var/www/cp, and /opt/registry."
|
||||
read -p "Are you sure you want to proceed? (y/n): " confirm
|
||||
|
||||
# Check user input
|
||||
if [[ "$confirm" != "y" ]]; then
|
||||
echo "Upgrade aborted."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create backup directory
|
||||
backup_dir="/opt/backup"
|
||||
mkdir -p "$backup_dir"
|
||||
|
||||
# Backup directories
|
||||
echo "Creating backups..."
|
||||
tar -czf "$backup_dir/cp_backup_$(date +%F).tar.gz" -C / var/www/cp
|
||||
tar -czf "$backup_dir/whois_backup_$(date +%F).tar.gz" -C / var/www/whois
|
||||
tar -czf "$backup_dir/registry_backup_$(date +%F).tar.gz" -C / opt/registry
|
||||
|
||||
# Database credentials
|
||||
config_file="/opt/registry/whois/port43/config.php"
|
||||
db_user=$(grep "'db_username'" "$config_file" | awk -F "=> '" '{print $2}' | sed "s/',//")
|
||||
db_pass=$(grep "'db_password'" "$config_file" | awk -F "=> '" '{print $2}' | sed "s/',//")
|
||||
db_host=$(grep "'db_host'" "$config_file" | awk -F "=> '" '{print $2}' | sed "s/',//")
|
||||
|
||||
# List of databases to back up
|
||||
databases=("registry" "registryAudit" "registryTransaction")
|
||||
|
||||
# Backup specific databases
|
||||
for db_name in "${databases[@]}"; do
|
||||
echo "Backing up database $db_name..."
|
||||
sql_backup_file="$backup_dir/db_${db_name}_backup_$(date +%F).sql"
|
||||
mysqldump -u"$db_user" -p"$db_pass" -h"$db_host" "$db_name" > "$sql_backup_file"
|
||||
|
||||
# Compress the SQL backup file
|
||||
echo "Compressing database backup $db_name..."
|
||||
tar -czf "${sql_backup_file}.tar.gz" -C "$backup_dir" "$(basename "$sql_backup_file")"
|
||||
|
||||
# Remove the uncompressed SQL file
|
||||
rm "$sql_backup_file"
|
||||
done
|
||||
|
||||
# Stop services
|
||||
echo "Stopping services..."
|
||||
systemctl stop caddy
|
||||
systemctl stop epp
|
||||
systemctl stop whois
|
||||
systemctl stop rdap
|
||||
systemctl stop das
|
||||
|
||||
# Clear cache
|
||||
echo "Clearing cache..."
|
||||
php /var/www/cp/bin/clear_cache.php
|
||||
|
||||
# Clone the new version of the repository
|
||||
echo "Cloning v1.0.13 from the repository..."
|
||||
git clone --branch v1.0.13 --single-branch https://github.com/getnamingo/registry /opt/registry1013
|
||||
|
||||
# Copy files from the new version to the appropriate directories
|
||||
echo "Copying files..."
|
||||
|
||||
# Function to copy files and maintain directory structure
|
||||
copy_files() {
|
||||
src_dir=$1
|
||||
dest_dir=$2
|
||||
|
||||
if [[ -d "$src_dir" ]]; then
|
||||
echo "Copying from $src_dir to $dest_dir..."
|
||||
cp -R "$src_dir/." "$dest_dir/"
|
||||
else
|
||||
echo "Source directory $src_dir does not exist. Skipping..."
|
||||
fi
|
||||
}
|
||||
|
||||
# Copy specific directories
|
||||
copy_files "/opt/registry1013/automation" "/opt/registry/automation"
|
||||
copy_files "/opt/registry1013/cp" "/var/www/cp"
|
||||
copy_files "/opt/registry1013/whois/web" "/var/www/whois"
|
||||
copy_files "/opt/registry1013/das" "/opt/registry/das"
|
||||
copy_files "/opt/registry1013/whois/port43" "/opt/registry/whois/port43"
|
||||
copy_files "/opt/registry1013/rdap" "/opt/registry/rdap"
|
||||
copy_files "/opt/registry1013/epp" "/opt/registry/epp"
|
||||
copy_files "/opt/registry1013/docs" "/opt/registry/docs"
|
||||
|
||||
# Run composer update in copied directories (excluding docs)
|
||||
echo "Running composer update..."
|
||||
|
||||
composer_update() {
|
||||
dir=$1
|
||||
if [[ -d "$dir" ]]; then
|
||||
echo "Updating composer in $dir..."
|
||||
cd "$dir" && composer update
|
||||
else
|
||||
echo "Directory $dir does not exist. Skipping composer update..."
|
||||
fi
|
||||
}
|
||||
|
||||
# Update composer in relevant directories
|
||||
composer_update "/opt/registry/automation"
|
||||
composer_update "/var/www/cp"
|
||||
composer_update "/opt/registry/das"
|
||||
composer_update "/opt/registry/whois/port43"
|
||||
composer_update "/opt/registry/rdap"
|
||||
composer_update "/opt/registry/epp"
|
||||
|
||||
cp /opt/registry/docs/msg_producer.service /etc/systemd/system/
|
||||
cp /opt/registry/docs/msg_worker.service /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
# Start services
|
||||
echo "Starting services..."
|
||||
systemctl start epp
|
||||
systemctl start whois
|
||||
systemctl start rdap
|
||||
systemctl start das
|
||||
systemctl start caddy
|
||||
|
||||
systemctl enable msg_producer
|
||||
systemctl enable msg_worker
|
||||
|
||||
# Check if services started successfully
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "Services started successfully. Deleting /opt/registry1013..."
|
||||
rm -rf /opt/registry1013
|
||||
else
|
||||
echo "There was an issue starting the services. /opt/registry1013 will not be deleted."
|
||||
fi
|
||||
|
||||
echo "Upgrade to v1.0.13 completed successfully."
|
||||
echo "Please configure and run your Message Broker with:"
|
||||
echo "systemctl start msg_producer"
|
||||
echo "systemctl start msg_worker"
|
Loading…
Add table
Add a link
Reference in a new issue