Jayden

Jayden

Automatic Update Mix-Space & Shiro

Force @innei to update every day, the speed of updating is so fast that in order to ensure that you can experience the latest features at any time, it is necessary to write a script to automatically update Mix-Space and Shiro every day.

Update Script#

My Mix-Space backend is deployed using Docker Compose, and the frontend is the closed-source version of Shiro called Shiroi, which is compiled and deployed.

The scripts for updating the frontend and backend are as follows:

#!/usr/bin/zsh

# Update the backend

echo "Start updating the backend..."
cd /root/mix-space/core
docker compose pull && docker compose up -d
echo "Backend update complete."

echo "---------------------------------------------"
# Update the frontend

cd /root/mix-space/Shiroi

output=$(git pull)
if [[ $output == *"Already up to date."* ]]; then
        echo "The frontend is already up to date, no need to update."
else
        echo "Start updating the frontend..."
        npm install -g pnpm
        npm install -g pm2
        echo "Start installing dependencies..."
        pnpm i
        echo "Dependency installation complete."
        echo "Start building..."
        pnpm build
        echo "Build complete."
        echo "Restarting the frontend..."
        pm2 remove 0
        pm2 start ecosystem.config.cjs
        echo "Frontend restart complete."
fi
echo "Last update time:"
date

Scheduled Execution#

I have set it to automatically update at 1:10 AM every day, and the log will be output to /root/sh/update.log, you can refer to it.

crontab -e
10 1 * * * /root/sh/mix-space-shiroi-update.sh >> /root/sh/update.log 2>&1

I am completely a novice in writing shell scripts, although it is not well-written, it is effective.

If you have any better ideas, please discuss them with me in the comment section.

This article is synchronized to xLog by Mix Space
The original link is https://xxu.do/posts/geek/update-Mix-Space-and-Shiro


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.