Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjh5
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data_server
gjjh5
Commits
4085d98c
Commit
4085d98c
authored
Feb 28, 2019
by
姜登
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gjj
parent
993cb511
Pipeline
#3981
passed with stage
in 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
2 deletions
+17
-2
scripts.js
app/service/scripts.js
+15
-2
config.local.js
config/config.local.js
+1
-0
config.prod.js
config/config.prod.js
+1
-0
No files found.
app/service/scripts.js
View file @
4085d98c
...
@@ -15,6 +15,7 @@ class ScriptsService extends Service {
...
@@ -15,6 +15,7 @@ class ScriptsService extends Service {
this
.
fetchHelpUrl
=
scriptsAPI
.
fetchHelpUrl
;
this
.
fetchHelpUrl
=
scriptsAPI
.
fetchHelpUrl
;
this
.
redisScriptsKey
=
scriptsAPI
.
redisScriptsKey
;
this
.
redisScriptsKey
=
scriptsAPI
.
redisScriptsKey
;
this
.
redisParamsKey
=
scriptsAPI
.
redisParamsKey
;
this
.
redisParamsKey
=
scriptsAPI
.
redisParamsKey
;
this
.
redisScriptListKey
=
scriptsAPI
.
redisScriptListKey
;
}
}
async
fetchScripts
()
{
async
fetchScripts
()
{
...
@@ -42,13 +43,25 @@ class ScriptsService extends Service {
...
@@ -42,13 +43,25 @@ class ScriptsService extends Service {
return
result
.
data
;
return
result
.
data
;
}
}
async
fetchOneScripts
(
scriptId
)
{
async
fetchOneScripts
(
scriptId
)
{
const
{
baseURL
,
fetchOneScriptUrl
,
ctx
}
=
this
;
const
{
baseURL
,
fetchOneScriptUrl
,
redisScriptListKey
,
ctx
}
=
this
;
const
data
=
await
this
.
app
.
cache
.
get
(
redisScriptListKey
+
scriptId
);
if
(
data
)
{
try
{
return
JSON
.
parse
(
data
);
}
catch
(
err
)
{
ctx
.
logger
.
error
(
'【Scripts】fetchOneScriptsFromRedis'
,
'result:'
,
data
,
err
);
await
this
.
app
.
cache
.
del
(
redisScriptListKey
+
scriptId
);
}
}
const
result
=
await
ctx
.
curl
(
baseURL
+
fetchOneScriptUrl
+
'/'
+
scriptId
,
{
const
result
=
await
ctx
.
curl
(
baseURL
+
fetchOneScriptUrl
+
'/'
+
scriptId
,
{
charset
:
'utf-8'
,
charset
:
'utf-8'
,
timeout
:
[
'30s'
,
'30s'
],
timeout
:
[
'30s'
,
'30s'
],
dataType
:
'json'
,
dataType
:
'json'
,
contentType
:
'json'
,
contentType
:
'json'
,
});
});
if
(
result
.
data
&&
(
String
(
result
.
data
.
id
)
===
scriptId
))
{
await
this
.
app
.
cache
.
set
(
redisScriptListKey
+
scriptId
,
JSON
.
stringify
(
result
.
data
),
60
);
}
return
result
.
data
;
return
result
.
data
;
}
}
...
@@ -162,7 +175,7 @@ class ScriptsService extends Service {
...
@@ -162,7 +175,7 @@ class ScriptsService extends Service {
async
fetchScriptName
(
scriptId
)
{
async
fetchScriptName
(
scriptId
)
{
try
{
try
{
const
city
=
await
this
.
fetchOneScripts
(
scriptId
);
const
city
=
await
this
.
fetchOneScripts
(
scriptId
);
return
city
.
name
;
return
city
.
name
||
'未知'
;
}
catch
(
err
)
{
}
catch
(
err
)
{
return
'未知'
;
return
'未知'
;
}
}
...
...
config/config.local.js
View file @
4085d98c
...
@@ -45,6 +45,7 @@ module.exports = () => {
...
@@ -45,6 +45,7 @@ module.exports = () => {
fetchScriptByCityNameUrl
:
'/chaos/hf/city_scripts'
,
fetchScriptByCityNameUrl
:
'/chaos/hf/city_scripts'
,
redisScriptsKey
:
'URANUS.HF.SCRIPTS'
,
redisScriptsKey
:
'URANUS.HF.SCRIPTS'
,
redisParamsKey
:
'URANUS.HF.PARAMS'
,
redisParamsKey
:
'URANUS.HF.PARAMS'
,
redisScriptListKey
:
'URANUS.HF.SCRIPTLIST'
,
};
};
config
.
storageAPI
=
{
config
.
storageAPI
=
{
...
...
config/config.prod.js
View file @
4085d98c
...
@@ -38,6 +38,7 @@ module.exports = () => {
...
@@ -38,6 +38,7 @@ module.exports = () => {
fetchScriptByCityNameUrl
:
'/chaos/hf/city_scripts'
,
fetchScriptByCityNameUrl
:
'/chaos/hf/city_scripts'
,
redisScriptsKey
:
'URANUS.HF.SCRIPTS'
,
redisScriptsKey
:
'URANUS.HF.SCRIPTS'
,
redisParamsKey
:
'URANUS.HF.PARAMS'
,
redisParamsKey
:
'URANUS.HF.PARAMS'
,
redisScriptListKey
:
'URANUS.HF.SCRIPTLIST'
,
};
};
config
.
storageAPI
=
{
config
.
storageAPI
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment