فهرست منبع

竞价服务器申请配置调整

mxs 7 ماه پیش
والد
کامیت
bb90797eae
6فایلهای تغییر یافته به همراه41 افزوده شده و 24 حذف شده
  1. 2 2
      src/task/task.go
  2. 8 1
      src/taskManager/taskManager.go
  3. 11 9
      src/vps/aliecs.go
  4. 2 2
      src/vpsconfig.json
  5. 6 2
      src/web/templates/mytask.html
  6. 12 8
      src/web/templates/task.html

+ 2 - 2
src/task/task.go

@@ -25,7 +25,7 @@ func (t *Task) TaskList() {
 	taskState, _ := t.GetInteger("taskState") //任务状态
 	event, _ := t.GetInteger("taskEvent")     //节点
 	stype, _ := t.GetInteger("taskStype")     //任务类型
-	platform := t.GetString("platform")       //任务类型
+	platform := t.GetString("platform")       //平台
 	userid := t.GetString("userid")
 	searchStr := t.GetString("search[value]")
 	//search := strings.Replace(searchStr, " ", "", -1)
@@ -92,7 +92,7 @@ func (t *Task) TaskList() {
 	}
 }
 
-//编辑 查看任务
+// 编辑 查看任务
 func (t *Task) TaskEdit(ids string) error {
 	auth := qu.IntAll(t.GetSession("auth"))
 	id := strings.Split(ids, "__")[0]

+ 8 - 1
src/taskManager/taskManager.go

@@ -117,6 +117,8 @@ func (t *TaskM) Taskfile() {
 							stype = "2"
 						} else if stype == "数量异常" {
 							stype = "1"
+						} else if stype == "常规任务" {
+							stype = "0"
 						} else {
 							errorinfo[cells[0].Value] = "第" + fmt.Sprint(k+1) + "行任务类型填写错误"
 							continue
@@ -147,6 +149,8 @@ func (t *TaskM) Taskfile() {
 							o["l_complete"] = completeTime
 							o["i_pendstate"] = 0
 							o["l_checktime"] = time.Now().Unix()
+							o["i_count"] = 0
+							o["f_failrate"] = float64(0)
 							u.MgoEB.Save("task", o)
 							//清空map
 							o = map[string]interface{}{}
@@ -219,15 +223,16 @@ func (t *TaskM) ManagerTask() {
 				//sort = `{"l_complete":1,` + sortb + `}`
 				sort = `{` + sortb + `,"l_complete":1}`
 			}
-			qu.Debug("query:", query, sort)
 			task, _ := u.MgoEB.Find("task", query, sort, nil, false, start, limit)
 			count := u.MgoEB.Count("task", query)
+			qu.Debug("query:", query, sort, start, limit, len(*task), count)
 			page := start / 10
 			if len(*task) > 0 {
 				for k, v := range *task {
 					v["num"] = k + 1 + page*10
 					v["encode"] = util.Se.Encode2Hex(fmt.Sprint(v["s_code"]))
 					v["_id"] = mongodb.BsonIdToSId(v["_id"])
+
 					//根据code查询luaconfig
 					lua, _ := u.MgoEB.FindOneByField("luaconfig", map[string]interface{}{"code": qu.ObjToString(v["s_code"])}, `{"href":1}`)
 					if len(*lua) > 0 {
@@ -420,6 +425,8 @@ func (t *TaskM) SaveNewTask() {
 	newTask["i_frequencyerrtimes"] = 0 //采集频率异常次数
 	newTask["s_platform"] = "golua平台"
 	newTask["i_num"] = 0
+	newTask["i_count"] = 0
+	newTask["f_failrate"] = float64(0)
 	queryL := map[string]interface{}{
 		"code": code,
 	}

+ 11 - 9
src/vps/aliecs.go

@@ -1,6 +1,8 @@
-/**
+/*
+*
 阿里云ecs实例自动申请、部署、释放
-**/
+*
+*/
 package vps
 
 import (
@@ -28,7 +30,7 @@ const (
 	URL      = "https://ecs.aliyuncs.com"
 )
 
-//批量创建实例
+// 批量创建实例
 func RunInstances(name, image, region, zoneid, launchTemplateId string, public bool, num, hours int, ok *bool) {
 	defer qu.Catch()
 	widthOut := "0"
@@ -59,7 +61,7 @@ func runInstances(name, widthOut, region, zoneid, launchTemplateId, imageId stri
 	applyOk := false
 	qu.Debug(launchTemplateId)
 	if hours == 0 { //表示无期限
-		hours = 24 * 365 * 3 //阿里竞价服务器最长申请3年
+		hours = 24 * 365 * 1 //阿里竞价服务器最长申请3年
 	}
 	autoReleaseTime := time.Now().Add(time.Duration(hours) * time.Hour).UTC().Format("2006-01-02T15:04:05Z")
 	param := [][]string{
@@ -107,7 +109,7 @@ func runInstances(name, widthOut, region, zoneid, launchTemplateId, imageId stri
 	return applyOk
 }
 
-//查询多台实例的详细信息
+// 查询多台实例的详细信息
 func DescribeInstances(ok *bool) {
 	for regionid, _ := range VpsConfig.Regions {
 		qu.Debug("regionid:", regionid)
@@ -143,7 +145,7 @@ func DescribeInstances(ok *bool) {
 	}
 }
 
-//停止实例
+// 停止实例
 func StopInstance(InstanceId string) {
 	res := GET("StopInstance", [][]string{
 		[]string{"InstanceId", InstanceId},
@@ -152,7 +154,7 @@ func StopInstance(InstanceId string) {
 	log.Println("StopInstance", res)
 }
 
-//释放实例
+// 释放实例
 func DeleteInstance(InstanceId string, ok *bool) {
 	res := GET("DeleteInstance", [][]string{
 		[]string{"InstanceId", InstanceId},
@@ -164,7 +166,7 @@ func DeleteInstance(InstanceId string, ok *bool) {
 	qu.Debug("DeleteInstance", res)
 }
 
-//实例自动释放时间
+// 实例自动释放时间
 func ModifyInstanceAutoReleaseTime(InstanceId, regionId string, hours int, ok *bool) {
 	qu.Debug(VpsConfig.AccessId, time.Now().Add(time.Duration(hours)*time.Hour).UTC().Format("2006-01-02T15:04:05Z"))
 	res := GET("ModifyInstanceAutoReleaseTime", [][]string{
@@ -176,7 +178,7 @@ func ModifyInstanceAutoReleaseTime(InstanceId, regionId string, hours int, ok *b
 	qu.Debug("ModifyInstanceAutoReleaseTime", res)
 }
 
-//GET请求
+// GET请求
 func GET(action string, param [][]string) (mres map[string]interface{}) {
 	ps := &paramSorter{[]string{
 		"Format",

+ 2 - 2
src/vpsconfig.json

@@ -6,8 +6,8 @@
     "cn-beijing": {
       "regionname": "北京",
       "zoneids": {
-        "cn-beijing-h": {
-          "vswitchid": "vsw-2zeohlapv0uorsiayr1fv",
+        "cn-beijing-f": {
+          "vswitchid": "vsw-2ze1w617fx53vk90qmi1u",
           "launchtemplateids": {
             "4": "lt-2zecgkiku3ge497fk7ea",
             "8": "lt-2ze9dvtb8f0x7rqw0r51"

+ 6 - 2
src/web/templates/mytask.html

@@ -25,6 +25,8 @@
 								<th>次数</th>
 <!--								<th>频率次数</th>-->
 								<th>来源</th>
+								<th>7日下载量</th>
+								<th>失败占比</th>
 								<th>最迟完成时间</th>
 <!--								<th>挂起</th>-->
 								<th class="hidden-xs">操作</th>
@@ -49,7 +51,7 @@
 				
        		 },
 			"columnDefs": [
-			    { "orderable": false, "targets": [0,1,2,3,4,5,9] },
+			    { "orderable": false, "targets": [0,1,2,3,4,5,10,11] },
 				//爬虫挂起
 				// {"targets":[11], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
 				// 		var aInput;
@@ -79,7 +81,7 @@
 				// 		});
 				// 	}}
 			],	
-      		"order": [[8,"desc"]], //默认排序列
+      		"order": [[10,"desc"]], //默认排序列
 			"lengthChange":false,
 			"serverSide": true,
 			"searching": true,
@@ -128,6 +130,8 @@
 					}},
 				{"data": "i_times"},
 				{"data": "s_source"},
+				{"data": "i_count"},
+				{"data": "f_failrate"},
 				{"data": "l_complete","width":"8%",render:function(val,a,row){
 						var dt = new Date()
 						dt.setTime(parseInt(val) * 1000);

+ 12 - 8
src/web/templates/task.html

@@ -77,7 +77,9 @@
 								<th>次数</th>
 <!--								<th>频率次数</th>-->
                 				<th>来源</th>
-								<th>最迟完成时间</th>
+                				<th>7日下载量</th>
+                				<th>失败占比</th>
+<!--								<th>最迟完成时间</th>-->
 <!--								<th>挂起</th>-->
 								<th class="hidden-xs">操作</th>
 							</tr>
@@ -106,9 +108,9 @@
        		 },
 			"columnDefs": [
 				{ "targets": 0 ,"bVisible": false}, //隐藏列
-				{ "orderable": false, "targets": [0,1,2,3,4,5,6,7,8,13] } //设置列不可排序
+				{ "orderable": false, "targets": [0,1,2,3,4,5,6,7,8,9,14] } //设置列不可排序
 			],
-			"order": [[12,"desc"]], //默认排序列
+			"order": [[13,"desc"]], //默认排序列
 			"lengthChange":false,
 			"serverSide": true,
 			"searching": true,
@@ -178,11 +180,13 @@
 				{"data": "i_event"},
 				{"data": "i_times"},
 				{"data": "s_source"},
-				{"data": "l_complete","width":"8%",render:function(val,a,row){
-					var dt = new Date()
-					dt.setTime(parseInt(val) * 1000);
-					return dt.format("yyyy-MM-dd hh:mm:ss");
-				}},
+				{"data": "i_count"},
+				{"data": "f_failrate"},
+				// {"data": "l_complete","width":"8%",render:function(val,a,row){
+				// 	var dt = new Date()
+				// 	dt.setTime(parseInt(val) * 1000);
+				// 	return dt.format("yyyy-MM-dd hh:mm:ss");
+				// }},
 				{"data": "_id","width":"10%",render:function(val,a,row){
 					var div=$("<div><div class=\"btn-group\"></div></div>")
 					var buttonWatch=$('<a type="button" target="_blank" class="btn btn-sm btn-primary">编辑</a>');