@name 创建内置项目 @author lkq<2021-08-27> @param domain 域名 @param tomcat_version tomcat版本 7 8 9 @param project_path 项目路径 @param project_ps 项目描述 @param bind_extranet 绑定外网 默认不需要传递 @return string
(self, get)
| 2929 | return self.create_spring_boot_project(get) |
| 2930 | |
| 2931 | def create_internal_project(self, get): |
| 2932 | ''' |
| 2933 | @name 创建内置项目 |
| 2934 | @author lkq<2021-08-27> |
| 2935 | @param domain 域名 |
| 2936 | @param tomcat_version tomcat版本 7 8 9 |
| 2937 | @param project_path 项目路径 |
| 2938 | @param project_ps 项目描述 |
| 2939 | @param bind_extranet 绑定外网 默认不需要传递 |
| 2940 | @return string |
| 2941 | ''' |
| 2942 | if not public.is_apache_nginx(): return public.returnMsg(False, '未安装Apache或Nginx') |
| 2943 | if not 'domain' in get: return public.returnMsg(False, '请指定域名!') |
| 2944 | if not 'tomcat_version' in get: return public.returnMsg(False, '请指定tomcat版本!') |
| 2945 | if not 'project_path' in get: return public.returnMsg(False, '请指定项目路径!') |
| 2946 | if not 'project_name' in get: |
| 2947 | get.project_name = get.domain |
| 2948 | else: |
| 2949 | get.project_name = get.domain |
| 2950 | if not 'bind_extranet' in get: |
| 2951 | get.bind_extranet = 1 |
| 2952 | else: |
| 2953 | get.bind_extranet = 1 |
| 2954 | domain = get.domain.strip() |
| 2955 | # 判断域名是合法性 |
| 2956 | if not self.is_domain(domain): return public.returnMsg(False, "请输入正确的域名") |
| 2957 | # 兼容PHP 判断域名是否存在 |
| 2958 | if public.M('domain').where('name=?', domain).count(): |
| 2959 | return public.returnMsg(False, '指定域名已存在: {}'.format(domain)) |
| 2960 | tomcat_version = str(get.tomcat_version) |
| 2961 | project_path = get.project_path.strip() |
| 2962 | if not os.path.exists(project_path): |
| 2963 | os.makedirs(project_path) |
| 2964 | public.set_own(project_path, 'www') |
| 2965 | # project_name = get.project_name.strip() |
| 2966 | tomcat_list = ["7", "8", "9"] |
| 2967 | if not tomcat_version in tomcat_list: return public.returnMsg(False, '请指定tomcat版本!') |
| 2968 | # 判断tomcat是否存在 |
| 2969 | tomcat_info = self.get_tomcat_info(tomcat_version) |
| 2970 | if tomcat_info['stype'] == 'uninstall': return public.returnMsg(False, '选择的tomcat不存在!') |
| 2971 | |
| 2972 | # 如果为就旧版本启动文件更改启动文件 |
| 2973 | res = public.ExecShell('sed -n "142p" /usr/local/bttomcat/tomcat{}/bin/daemon.sh'.format(tomcat_version))[0] |
| 2974 | _path = '/www/wwwlogs/java/neizhi{}'.format(tomcat_version) |
| 2975 | if not os.path.exists(_path): |
| 2976 | os.makedirs(_path) |
| 2977 | if not res.startswith('test ".$CATALINA_OUT" = . && CATALINA_OUT="$CATALINA_BASE/logs/catalina-daemon.out"'): |
| 2978 | self._change_daemom_sh("/usr/local/bttomcat/tomcat%s/bin/daemon.sh" % tomcat_version, _path) |
| 2979 | |
| 2980 | # 初始化tomcat配置文件 |
| 2981 | if not self.Initialization(tomcat_version): return public.returnMsg( |
| 2982 | False, "tomcat%s配置文件错误或者服务未安装" % tomcat_version |
| 2983 | ) |
| 2984 | # 获取当前tomcat 的port |
| 2985 | tomcat_port = tomcat_info['port'] |
| 2986 | # 判断域名是否在tomcat中 |
| 2987 | if self.add_vhost(path = project_path, domain = domain): |
| 2988 | # 添加成功 |
no test coverage detected