@name 开机自动启动
(self)
| 2820 | return self._check_add_domain(project_name, res_domains) |
| 2821 | |
| 2822 | def auto_run(self): |
| 2823 | ''' |
| 2824 | @name 开机自动启动 |
| 2825 | ''' |
| 2826 | # 获取数据库信息 |
| 2827 | project_list = public.M('sites').where('project_type=?', ('Python',)).field('name,path,project_config').select() |
| 2828 | get = public.dict_obj() |
| 2829 | success_count = 0 |
| 2830 | error_count = 0 |
| 2831 | for project in project_list: |
| 2832 | project_config = json.loads(project['project_config']) |
| 2833 | if project_config['auto_run'] in [0, False, '0', None]: continue |
| 2834 | project_name = project['name'] |
| 2835 | project_state = self.get_project_run_state(project_name=project_name) |
| 2836 | if not project_state: |
| 2837 | get.name = project_name |
| 2838 | result = self.StartProject(get) |
| 2839 | if not result['status']: |
| 2840 | error_count += 1 |
| 2841 | error_msg = '自动启动Python项目[' + project_name + ']失败!' |
| 2842 | public.WriteLog(self._log_name, error_msg) |
| 2843 | else: |
| 2844 | success_count += 1 |
| 2845 | success_msg = '自动启动Python项目[' + project_name + ']成功!' |
| 2846 | public.WriteLog(self._log_name, success_msg) |
| 2847 | if (success_count + error_count) < 1: return False |
| 2848 | dene_msg = '共需要启动{}个Python项目,成功{}个,失败{}个'.format(success_count + error_count, success_count, |
| 2849 | error_count) |
| 2850 | public.WriteLog(self._log_name, dene_msg) |
| 2851 | return True |
| 2852 | |
| 2853 | # ————————————— |
| 2854 | # 日志切割 | |
nothing calls this directly
no test coverage detected