mirror of https://gitee.com/anolis/sysom.git
!589 update vmcore server scripts
Merge pull request !589 from huangtuq/auto-10224282-master-f14e5d94
This commit is contained in:
commit
2d9078019c
|
@ -1,14 +1,15 @@
|
|||
#!/bin/bash
|
||||
SERVICE_NAME=sysom-vmcore
|
||||
stop_app() {
|
||||
clear_app() {
|
||||
sed -i '/vmcore/d' /var/spool/cron/root
|
||||
sed -i '/vmcore/d' /etc/exports
|
||||
exportfs -rv
|
||||
systemctl stop nfs-server
|
||||
systemctl stop rpcbind
|
||||
systemctl stop nfs
|
||||
supervisorctl stop $SERVICE_NAME
|
||||
rm -rf /etc/supervisord.d/${SERVICE_NAME}.ini
|
||||
###use supervisorctl update to stop and clear services###
|
||||
supervisorctl update
|
||||
}
|
||||
|
||||
stop_app
|
||||
clear_app
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
init_server.sh
|
|
@ -0,0 +1,69 @@
|
|||
#! /bin/bash
|
||||
SERVER_DIR="sysom_server"
|
||||
VMCORE_DIR=${SERVER_DIR}/sysom_vmcore
|
||||
VIRTUALENV_HOME=${SERVER_HOME}/virtualenv
|
||||
TARGET_PATH=${SERVER_HOME}/target
|
||||
SERVICE_NAME=sysom-vmcore
|
||||
|
||||
source_virtualenv() {
|
||||
echo "INFO: activate virtualenv..."
|
||||
source ${VIRTUALENV_HOME}/bin/activate || exit 1
|
||||
}
|
||||
|
||||
init_conf() {
|
||||
pushd ${TARGET_PATH}/${VMCORE_DIR}
|
||||
rm -f apps/*/migrations/00*.py
|
||||
python manage.py makemigrations vmcore
|
||||
python manage.py migrate
|
||||
popd
|
||||
|
||||
cp ${SERVICE_NAME}.ini /etc/supervisord.d/
|
||||
###change the install dir base on param $1###
|
||||
sed -i "s;/usr/local/sysom;${APP_HOME};g" /etc/supervisord.d/${SERVICE_NAME}.ini
|
||||
}
|
||||
|
||||
start_app() {
|
||||
###if supervisor service started, we need use "supervisorctl update" to start new conf####
|
||||
supervisorctl update
|
||||
supervisorctl status ${SERVICE_NAME}
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "supervisorctl start ${SERVICE_NAME} success..."
|
||||
return 0
|
||||
fi
|
||||
echo "${SERVICE_NAME} service start fail, please check log"
|
||||
exit 1
|
||||
}
|
||||
|
||||
start_nfs()
|
||||
{
|
||||
systemctl start rpcbind && systemctl enable rpcbind
|
||||
systemctl start nfs && systemctl enable nfs
|
||||
if [ $? -ne 0 ];then
|
||||
systemctl start nfs-server && systemctl enable nfs-server
|
||||
fi
|
||||
|
||||
nfs_mask=`ip -4 route | grep "link src" | grep $SERVER_LOCAL_IP | awk '{print $1}' | head -n 1`
|
||||
file_path=${SERVER_HOME}/vmcore/vmcore-nfs
|
||||
mkdir -p ${file_path}
|
||||
echo "${file_path} ${nfs_mask}(rw,async)" >> /etc/exports
|
||||
exportfs -rv
|
||||
chmod -R 777 ${file_path}
|
||||
}
|
||||
|
||||
start_cron()
|
||||
{
|
||||
cp parse_panic.py ${SERVER_HOME}/vmcore
|
||||
cp vmcore_const.py ${SERVER_HOME}/vmcore
|
||||
echo "* * * * * pushd ${SERVER_HOME}/vmcore;python3 parse_panic.py ${file_path} ${SERVER_PORT};popd" >> /var/spool/cron/root
|
||||
}
|
||||
|
||||
deploy() {
|
||||
source_virtualenv
|
||||
init_conf
|
||||
start_app
|
||||
start_nfs
|
||||
start_cron
|
||||
}
|
||||
|
||||
deploy
|
|
@ -1,69 +0,0 @@
|
|||
#! /bin/bash
|
||||
SERVER_DIR="sysom_server"
|
||||
VMCORE_DIR=${SERVER_DIR}/sysom_vmcore
|
||||
VIRTUALENV_HOME=${SERVER_HOME}/virtualenv
|
||||
TARGET_PATH=${SERVER_HOME}/target
|
||||
SERVICE_NAME=sysom-vmcore
|
||||
|
||||
source_virtualenv() {
|
||||
echo "INFO: activate virtualenv..."
|
||||
source ${VIRTUALENV_HOME}/bin/activate || exit 1
|
||||
}
|
||||
|
||||
init_conf() {
|
||||
pushd ${TARGET_PATH}/${VMCORE_DIR}
|
||||
rm -f apps/*/migrations/00*.py
|
||||
python manage.py makemigrations vmcore
|
||||
python manage.py migrate
|
||||
popd
|
||||
|
||||
cp ${SERVICE_NAME}.ini /etc/supervisord.d/
|
||||
###change the install dir base on param $1###
|
||||
sed -i "s;/usr/local/sysom;${APP_HOME};g" /etc/supervisord.d/${SERVICE_NAME}.ini
|
||||
}
|
||||
|
||||
start_app() {
|
||||
###if supervisor service started, we need use "supervisorctl update" to start new conf####
|
||||
supervisorctl update
|
||||
supervisorctl status ${SERVICE_NAME}
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "supervisorctl start ${SERVICE_NAME} success..."
|
||||
return 0
|
||||
fi
|
||||
echo "${SERVICE_NAME} service start fail, please check log"
|
||||
exit 1
|
||||
}
|
||||
|
||||
start_nfs()
|
||||
{
|
||||
systemctl start rpcbind && systemctl enable rpcbind
|
||||
systemctl start nfs && systemctl enable nfs
|
||||
if [ $? -ne 0 ];then
|
||||
systemctl start nfs-server && systemctl enable nfs-server
|
||||
fi
|
||||
|
||||
nfs_mask=`ip -4 route | grep "link src" | grep $SERVER_LOCAL_IP | awk '{print $1}' | head -n 1`
|
||||
file_path=${SERVER_HOME}/vmcore/vmcore-nfs
|
||||
mkdir -p ${file_path}
|
||||
echo "${file_path} ${nfs_mask}(rw,async)" >> /etc/exports
|
||||
exportfs -rv
|
||||
chmod -R 777 ${file_path}
|
||||
}
|
||||
|
||||
start_cron()
|
||||
{
|
||||
cp parse_panic.py ${SERVER_HOME}/vmcore
|
||||
cp vmcore_const.py ${SERVER_HOME}/vmcore
|
||||
echo "* * * * * pushd ${SERVER_HOME}/vmcore;python3 parse_panic.py ${file_path} ${SERVER_PORT};popd" >> /var/spool/cron/root
|
||||
}
|
||||
|
||||
deploy() {
|
||||
source_virtualenv
|
||||
init_conf
|
||||
start_app
|
||||
start_nfs
|
||||
start_cron
|
||||
}
|
||||
|
||||
deploy
|
|
@ -1 +0,0 @@
|
|||
init.sh
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
SERVICE_NAME=sysom-vmcore
|
||||
start_app() {
|
||||
systemctl start nfs-server
|
||||
systemctl start rpcbind
|
||||
systemctl start nfs
|
||||
sed -i '/vmcore/s;^#;;g' /var/spool/cron/root
|
||||
sed -i '/vmcore/s;^#;;g' /etc/exports
|
||||
exportfs -rv
|
||||
supervisorctl start $SERVICE_NAME
|
||||
}
|
||||
|
||||
start_app
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
SERVICE_NAME=sysom-vmcore
|
||||
stop_app() {
|
||||
sed -i '/vmcore/d' /var/spool/cron/root
|
||||
sed -i '/vmcore/d' /etc/exports
|
||||
sed -i '/vmcore/s;^;#;g' /var/spool/cron/root
|
||||
sed -i '/vmcore/s;^;#;g' /etc/exports
|
||||
exportfs -rv
|
||||
systemctl stop nfs-server
|
||||
systemctl stop rpcbind
|
||||
|
|
Loading…
Reference in New Issue