Pushing @innei to update every day is necessary to ensure the latest features are always available. Writing a script to automatically update Mix-Space and Shiro daily is highly recommended.
Update Script#
My Mix-Space backend is deployed using Docker Compose, while the frontend is the closed-source version of Shiro called Shiroi, which is compiled and deployed.
Here is the script to update the frontend and backend:
#!/usr/bin/zsh
# Update backend
echo "Updating the backend..."
cd /root/mix-space/core
docker compose pull && docker compose up -d
echo "Backend update complete."
echo "---------------------------------------------"
# Update 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 "Updating the frontend..."
npm install -g pnpm
npm install -g pm2
echo "Installing dependencies..."
pnpm i
echo "Dependency installation complete."
echo "Compiling..."
pnpm build
echo "Compilation 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 output the log 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 at writing shell scripts. Although it may not be well-written, it is effective.
If you have any better ideas, please feel free to discuss them with me in the comments section.
This article is synchronized to xLog by Mix Space
The original link is https://xxu.do/posts/geek/update-Mix-Space-and-Shiro