introduction
Code Publishing System is an Internet company the necessary operation and maintenance system, the role of the main business users to publish code to the server business
Why do you need the code distribution system
Some students may say that our company server so one, to be a publishing system is too cumbersome? I do not agree with this statement
Distribution system has the following advantages
Process management, plus rights management , you can keep track of who did what in the operating system
Reduce human error affected the login server operation itself is possible misuse of
Operation and maintenance of automation for the operation and maintenance burdens
Facilitate publication without manual login N servers released
Fast and easy rollback version
Technology Selection
git: code management tool git use notes
rsync: a synchronization code to specify the server
Yii2: php mvc framework
Bootstrap3: front-end framework
jquery: js library
Code Publishing System
FIG flow frame
Web interface operation, process management, submission publishing tasks
Timing script gets publishing tasks
Develop synchronization strategy release code
Interface operation, process management
Process management personnel more time particularly evident advantages, many people hand-mixed easily go wrong. So join in the code release process management system is also advancing with the times
The figure is a more complete flow diagram I drew (before the company realized in such a complicated process), as described below
New development branch
Local development and commit code
Publish to test server
Testers test
After waiting for approval by the test line executive (not by re-take the test steps 2-4)
Published on-line
Project Manager product acceptance
Project completion
PS: 1,3,6 which is the business logic (scripts need help), others are flow control
Timing script gets publishing tasks
Through process control tasks will be published on-line push queue to go, you need to have scripting consumer queue tasks, on the timing of the script I did not choose to use crontab, the lowest since the beginning of the crontab is not satisfied minute business needs, it is recommended to write a permanent memory the shell, the following run once every 2 seconds
#!/bin/sh
cmd='php yii release/index'
while true
do
if [ $(ps -ef |grep '$cmd' |grep -v grep|wc -l) -eq 0 ];then
eval $cmd
sleep 3;
else
echo 'queue is Running';
fi
done
Script release / index Source Address: https://github.com/apanly/dream/blob/master/console/controllers/ReleaseController.php
Link configuration
'ops_repo' => [
"dream_blog" => [
'title' => '博客',
'feature' => [
'path' => '/home/www/yii_tools/tools'
],
'remote' => [
'hosts' => [ ],
'path' => '/home/www/yii_tools/dream',
'ssh_param' => ' -i /home/www/.ssh/publish_rsa www@'
],
'version' => [
'/tmp/release_version/version_blog'
]
]
]
Develop synchronization strategy release code
About synchronization strategy I practiced several, using different strategies depending on the situation, only the following is a personal experience
Excess separate service server 10 is recommended to use less than 20 rsync pushed to the target server (in this case, if the operation git directly on the target server is slow, and the source server little high load)
Fewer than 10 separate business server implementation of the recommendations git commands directly on the target server (of course, you can also rsync)
Examples show
(Figure 1)
(Figure II)
(Figure 3)
(Figure IV)
Figure 1: shows the task list is released
Figure 2: shows task is to add a release operation
Figure 3: shows the release of the task execution process instruction executed
Figure 4: is a supplement to Figure III, because I blog system is very simple and there is no remote (remote) server, just update the local server, so the Figure Four shots is original in the company doing system release remote code output of the Figure III remote objects supplement
PS: operation object version is the version number of the operation, the role of two
Static resource plus a version number, the browser will visit (action to achieve penetration browser cache) re-requested resources
Version rollback
As shown below
Reference material
Original Address: [tool] operation and maintenance systems Git code released
Tags: git distribution system operation and maintenance rsync
Intelligent Recommendation
- [Android] No.2 Ionic package
- crontab execution system time and time inconsistency
- [Important] No. outside it, we released the demo system
- [Java] one server to configure multiple Tomcat
- Canary release, rolling release, blue, green and released in the end what is the difference? The key point is what?
Reproduced in: https: //my.oschina.net/54php/blog/791750