zoukankan      html  css  js  c++  java
  • linux下服务启动脚本

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # @File : deployment.py
    # @Author: Anthony.waa
    # @Date : 2018/6/26 0026
    # @Desc :

    # 服务启动
    import os
    import time


    path = '/opt/data/'
    files = os.listdir(path)
    for file in files:
    '''
    # 遍历当前文件夹中所有文件
    # 使用linux系统命令启动path路径下所有jar程序,并设置间隔为1秒

    '''
    # 拼接程序所在路径
    split_path = path + file
    split_path_service = split_path.split('/')[3]
    process_info = os.popen("ps aux|grep microservice|grep -v grep|awk -F ' ' '{print $14}'")
    # 判断服务是否已经启动,如果进程存在则跳过,不存在启动服务
    if split_path_service not in process_info.read():
    # 程序启动命令
    cmding = 'nohup java -jar -Dspring.profiles.active=test %s >/dev/null 2>&1 & ' % split_path
    time.sleep(0.2)
    os.system(cmding)

    else:
    print('%s下的进程已经存在' % split_path_service)

    os.system('ps aux|grep microservice')
  • 相关阅读:
    作为另一个函数的值(读书摘)
    算法-二分查找与二叉排序树
    算法-图
    算法-二叉树
    算法-分治
    算法-回溯
    算法-动态规划
    算法-贪心
    算法-堆
    算法-栈,队列
  • 原文地址:https://www.cnblogs.com/ipyanthony/p/9230669.html
Copyright © 2011-2022 走看看