MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / create_independent_project

Method create_independent_project

class/projectModel/javaModel.py:3038–3211  ·  view source on GitHub ↗

@name 创建独立项目 @author lkq<2021-08-27> @param domain 域名 @param project_path 项目路径 @param port 端口号 @param tomcat_version 项目tomcat版本 7 8 9 #param project_ps 项目描述 @param auth 开机自动启动

(self, get)

Source from the content-addressed store, hash-verified

3036 return public.returnMsg(False, "添加失败")
3037
3038 def create_independent_project(self, get):
3039 ''&#x27;
3040 @name 创建独立项目
3041 @author lkq<2021-08-27>
3042 @param domain 域名
3043 @param project_path 项目路径
3044 @param port 端口号
3045 @param tomcat_version 项目tomcat版本 7 8 9
3046 #param project_ps 项目描述
3047 @param auth 开机自动启动
3048 ''&#x27;
3049 # 检查是否安装Apache或者Nginx
3050 if not public.is_apache_nginx(): return public.returnMsg(False, '未安装Apache或Nginx')
3051 if 'auto' not in get: get.auto = '0'
3052 port = get.port
3053 project_path = get.project_path.strip()
3054 # project_name=get.project_name.strip()
3055 if not hasattr(get, "tomcat_version"):
3056 return public.returnMsg(False, '未指定Tomcat版本')
3057 tomcat_version = str(get.tomcat_version)
3058 domain = get.domain.strip()
3059 if not 'project_name' in get:
3060 get.project_name = get.domain
3061 else:
3062 get.project_name = get.domain
3063 if hasattr(get, 'jdk_path'):
3064 jdk_path = get.jdk_path.strip()
3065 else:
3066 jdk_path = "/usr/local/btjdk/jdk8"
3067 # 判断域名是合法性
3068 if not self.is_domain(domain): return public.returnMsg(False, "请输入正确的域名")
3069 # 兼容PHP 判断域名是否存在
3070 if public.M('domain').where('name=?', domain).count():
3071 return public.returnMsg(False, '指定域名已存在: {}'.format(domain))
3072 if 'bind_extranet' in get:
3073 get.bind_extranet = 1
3074 else:
3075 get.bind_extranet = 1
3076 tomcat_list = ["7", "8", "9"]
3077 if not tomcat_version in tomcat_list: return public.returnMsg(False, '请指定tomcat版本!')
3078 if int(port) < 1 or int(port) > 65535: return public.returnMsg(False, '端口范围不合法')
3079 if self.check_port(port): return public.returnMsg(False, "端口被占用, 请更换其他端口")
3080 # 判断是否存在
3081 if os.path.exists(self.__site_path + domain): return public.returnMsg(
3082 False, "该网站已经存在。如想建立请删除%s" % self.__site_path + domain
3083 )
3084 if not os.path.exists(project_path):
3085 os.makedirs(project_path)
3086 public.set_own(project_path, 'www')
3087 # 首先需要先复制好文件过去
3088 if not os.path.exists(self.__site_path + domain):
3089 public.ExecShell('mkdir -p %s' % self.__site_path + domain)
3090 if tomcat_version == 'tomcat7' or tomcat_version == '7':
3091 if not os.path.exists(self.__tomcat7_path_bak + '/conf/server.xml'): return public.returnMsg(
3092 False, "tomcat7的配置文件不存在,请重新安装tomcat7"
3093 )
3094 public.ExecShell(
3095 'cp -r %s/* %s && chown -R www:www %s' % (

Callers 1

create_projectMethod · 0.95

Calls 15

check_portMethod · 0.95
_change_daemom_shMethod · 0.95
Initialization2Method · 0.95
set_site_portMethod · 0.95
add_vhostMethod · 0.95
set_hostsMethod · 0.95
project_add_domainMethod · 0.95
set_configMethod · 0.95
returnMsgMethod · 0.80
ExecShellMethod · 0.80
generate_random_portMethod · 0.80

Tested by

no test coverage detected