@name 创建Spring_boot项目 @author lkq<2021-08-27> @param domains 域名 可选 @param project_jar 项目jar路径 @param project_name 项目名称 @param port 项目端口号 @param project_jdk 项目JDK @param project_cmd 最终执行的命令 @parcm run_user 项目用户
(self, get)
| 3241 | return 'http://127.0.0.1:6611' |
| 3242 | |
| 3243 | def create_spring_boot_project(self, get): |
| 3244 | ''' |
| 3245 | @name 创建Spring_boot项目 |
| 3246 | @author lkq<2021-08-27> |
| 3247 | @param domains 域名 可选 |
| 3248 | @param project_jar 项目jar路径 |
| 3249 | @param project_name 项目名称 |
| 3250 | @param port 项目端口号 |
| 3251 | @param project_jdk 项目JDK |
| 3252 | @param project_cmd 最终执行的命令 |
| 3253 | @parcm run_user 项目用户 |
| 3254 | @parcm bind_extranet 是否绑定外网 |
| 3255 | @param auth 开启自启动 |
| 3256 | @parcm project_ps 描述 |
| 3257 | ''' |
| 3258 | self.set_spring_user() |
| 3259 | if get.run_user != 'root': |
| 3260 | ret = public.ReadFile('/etc/passwd') |
| 3261 | if isinstance(ret, str): |
| 3262 | rec = 'springboot' |
| 3263 | if not re.search(rec, ret): |
| 3264 | return public.returnMsg( |
| 3265 | False, 'springboot用户建立失败,疑是安全软件拦截。手动建立用户操作如下: useradd -s /sbin/nologin springboot' |
| 3266 | ) |
| 3267 | else: |
| 3268 | return public.returnMsg( |
| 3269 | False, 'springboot用户建立失败,疑是安全软件拦截。手动建立用户操作如下: useradd -s /sbin/nologin springboot' |
| 3270 | ) |
| 3271 | if not 'project_jdk' in get: return public.returnMsg(False, "请输入你的JDK路径") |
| 3272 | if not 'project_jar' in get: return public.returnMsg(False, "请输入你的jar路径") |
| 3273 | if not 'project_name' in get and get.project_name.strip(): return public.returnMsg(False, "请输入你的项目名称") |
| 3274 | if not 'port' in get: return public.returnMsg(False, "请输入你的项目端口号") |
| 3275 | if not 'run_user' in get: return public.returnMsg(False, "请输入你的项目用户") |
| 3276 | # if not 'auth' in get: return public.returnMsg(False, "请输入是否开机自启动") |
| 3277 | if not 'project_cmd' in get: return public.returnMsg(False, "请输入你的项目启动命令") |
| 3278 | if not hasattr(get, 'project_ps'): return public.returnMsg(False, "请输入你的项目启动命令") |
| 3279 | if not 'project_ps' in get: get.project_ps = '' |
| 3280 | if not 'is_separation' in get: get.is_separation = 0 |
| 3281 | get.project_name = get.project_name.strip() |
| 3282 | if public.M('sites').where('name=? ', (get.project_name,)).count(): |
| 3283 | return public.return_error('指定项目名称已存在: {}'.format(get.project_name)) |
| 3284 | project_path = os.path.dirname(get.project_jar) |
| 3285 | if not public.check_site_path(project_path): |
| 3286 | a, c = public.get_sys_path() |
| 3287 | return public.returnMsg(False, '请不要项目文件放到以下关键目录中: <br>{}'.format("<br>".join(a + c))) |
| 3288 | |
| 3289 | if get.is_separation: |
| 3290 | if public.get_webserver() == 'apache': |
| 3291 | return public.returnMsg(False, "前后端分离不支持Apache") |
| 3292 | get.is_separation = 1 |
| 3293 | ##静态资源目录 |
| 3294 | if get.is_separation and ('static_path' not in get or not get.static_path.strip()): |
| 3295 | get.static_path = '/www/wwwroot/' + get.project_name.split('/')[0] |
| 3296 | if 'api_url' not in get or not get.api_url.strip(): |
| 3297 | get.api_url = '/' |
| 3298 | elif get.api_url != '/' and get.api_url[-1] == '/': |
| 3299 | get.api_url = get.api_url[:-1] |
| 3300 | if not hasattr(get, 'auth'): |
no test coverage detected