Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
TarsWeb
Commits
1cab677e
Commit
1cab677e
authored
6 years ago
by
clauseliu
Browse files
Options
Download
Email Patches
Plain Diff
修改了serverDao和TaskService两处,没有经过测试。可能有坑
parent
63f173ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
app/controller/deploy/DeployServerController.js
+1
-1
app/controller/deploy/DeployServerController.js
app/controller/panshi/PanshiController.js
+47
-6
app/controller/panshi/PanshiController.js
app/controller/token/tokenController.js
+32
-0
app/controller/token/tokenController.js
app/dao/ServerDao.js
+8
-6
app/dao/ServerDao.js
app/router/routerConf.js
+7
-0
app/router/routerConf.js
app/service/task/TaskService.js
+1
-1
app/service/task/TaskService.js
with
96 additions
and
14 deletions
+96
-14
app/controller/deploy/DeployServerController.js
+
1
-
1
View file @
1cab677e
...
...
@@ -50,8 +50,8 @@ const serverConfStruct = {
DeployServerController
.
deployServer
=
async
(
ctx
)
=>
{
var
params
=
ctx
.
paramsObj
;
try
{
let
panshiRegister
=
await
PanshiService
.
register
(
params
);
let
rst
=
await
ServerService
.
addServerConf
(
params
);
let
panshiRegister
=
await
PanshiService
.
register
(
params
);
rst
.
server_conf
=
util
.
viewFilter
(
rst
.
server_conf
,
serverConfStruct
);
ctx
.
makeResObj
(
200
,
''
,
rst
);
}
catch
(
e
)
{
...
...
This diff is collapsed.
Click to expand it.
app/controller/panshi/PanshiController.js
+
47
-
6
View file @
1cab677e
...
...
@@ -16,12 +16,16 @@
const
logger
=
require
(
'
../../logger
'
);
const
PanshiService
=
require
(
'
../../service/panshi/PanshiService
'
);
const
ServerService
=
require
(
'
../../service/server/ServerService
'
);
const
AuthService
=
require
(
'
../../service/auth/AuthService
'
);
const
TaskService
=
require
(
'
../../service/task/TaskService
'
);
const
util
=
require
(
'
../../tools/util
'
);
const
Pa
ge
Controller
=
{
const
Pa
nshi
Controller
=
{
};
Pa
ge
Controller
.
queryService
=
async
(
ctx
)
=>
{
Pa
nshi
Controller
.
queryService
=
async
(
ctx
)
=>
{
try
{
let
data
=
await
PanshiService
.
queryService
();
ctx
.
makeResObj
(
200
,
''
,
data
);
...
...
@@ -31,7 +35,7 @@ PageController.queryService = async (ctx) => {
}
};
Pa
ge
Controller
.
querySystem
=
async
(
ctx
)
=>
{
Pa
nshi
Controller
.
querySystem
=
async
(
ctx
)
=>
{
let
ServiceId
=
ctx
.
paramsObj
.
ServiceId
;
try
{
let
data
=
await
PanshiService
.
querySystem
({
ServiceId
});
...
...
@@ -42,7 +46,7 @@ PageController.querySystem = async (ctx) => {
}
};
Pa
ge
Controller
.
queryModule
=
async
(
ctx
)
=>
{
Pa
nshi
Controller
.
queryModule
=
async
(
ctx
)
=>
{
let
SystemId
=
ctx
.
paramsObj
.
SystemId
;
try
{
let
data
=
await
PanshiService
.
queryModule
({
SystemId
});
...
...
@@ -53,9 +57,46 @@ PageController.queryModule = async (ctx) => {
}
};
PanshiController
.
batchUndeployTars
=
async
(
ctx
)
=>
{
let
{
application
,
server_name
,
serial
=
true
}
=
ctx
.
paramsObj
;
try
{
if
(
!
await
AuthService
.
hasDevAuth
(
application
,
server_name
,
ctx
.
uid
))
{
ctx
.
makeNotAuthResObj
();
}
else
{
let
ret
=
await
ServerService
.
getServerConfList4Tree
({
application
,
serverName
:
server_name
});
let
serverId
=
ret
.
map
(
item
=>
item
.
id
);
let
data
=
{
status
:
0
,
// 0找不到服务,1下线成功,2部分成功,3失败
total
:
0
,
failCount
:
0
,
succCount
:
0
,
failMsg
:
''
,
succMsg
:
''
};
if
(
!
serverId
.
length
){
ctx
.
makeResObj
(
200
,
''
,
data
);
}
else
{
let
task_no
=
util
.
getUUID
().
toString
();
let
items
=
[];
serverId
.
forEach
(
id
=>
{
items
.
push
({
server_id
:
id
,
command
:
'
undeploy_tars
'
,
parameters
:
''
});
})
let
ret
=
await
TaskService
.
addTask
({
serial
,
items
,
task_no
});
console
.
info
(
ret
);
ctx
.
makeResObj
(
200
,
''
,
ret
);
}
}
}
catch
(
err
)
{
logger
.
error
(
'
[batchUndeployTars]
'
,
err
,
ctx
);
ctx
.
makeResObj
(
500
,
err
.
message
)
}
}
module
.
exports
=
PageController
;
\ No newline at end of file
module
.
exports
=
PanshiController
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/controller/token/tokenController.js
0 → 100644
+
32
-
0
View file @
1cab677e
/**
* Tencent is pleased to support the open source community by making Tars available.
*
* Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
const
logger
=
require
(
'
../../logger
'
);
const
AuthService
=
require
(
'
../../service/auth/AuthService
'
);
const
AdminService
=
require
(
'
../../service/admin/AdminService
'
);
const
TokenController
=
{}
TokenController
.
getTokens
=
async
(
ctx
)
=>
{
try
{
ctx
.
makeResObj
(
200
,
''
,
[]);
}
catch
(
e
)
{
logger
.
error
(
'
[TokenController.getTokens]:
'
,
e
,
ctx
);
ctx
.
makeErrResObj
(
e
);
}
}
module
.
exports
=
TokenController
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/dao/ServerDao.js
+
8
-
6
View file @
1cab677e
...
...
@@ -52,12 +52,14 @@ ServerDao.getServerConf = async(params) => {
params
.
application
!=
undefined
&&
(
where
.
application
=
params
.
application
);
params
.
serverName
!=
undefined
&&
(
where
.
server_name
=
params
.
serverName
);
params
.
nodeName
!=
undefined
&&
(
where
.
node_name
=
params
.
nodeName
);
if
(
params
.
enableSet
&&
params
.
enableSet
==
'
Y
'
)
{
params
.
setName
&&
(
where
.
set_name
=
params
.
setName
);
params
.
setArea
&&
(
where
.
set_area
=
params
.
setArea
);
params
.
setGroup
&&
(
where
.
set_group
=
params
.
setGroup
);
}
else
{
where
.
enable_set
=
'
N
'
if
(
params
.
enableSet
)
{
if
(
params
.
enableSet
==
'
Y
'
)
{
params
.
setName
&&
(
where
.
set_name
=
params
.
setName
);
params
.
setArea
&&
(
where
.
set_area
=
params
.
setArea
);
params
.
setGroup
&&
(
where
.
set_group
=
params
.
setGroup
);
}
else
{
where
.
enable_set
=
'
N
'
}
}
let
options
=
{
where
:
where
,
...
...
This diff is collapsed.
Click to expand it.
app/router/routerConf.js
+
7
-
0
View file @
1cab677e
...
...
@@ -34,6 +34,7 @@ const LocaleController = require('../controller/locale/LocaleController');
const
InfTestController
=
require
(
'
../controller/infTest/InfTestController
'
);
const
CallChainController
=
require
(
'
../controller/callChain/CallChainController
'
);
const
PanshiController
=
require
(
'
../controller/panshi/PanshiController
'
);
const
TokenController
=
require
(
'
../controller/token/tokenController
'
);
const
pageConf
=
[
//首页
...
...
@@ -158,6 +159,12 @@ const apiConf = [
[
'
get
'
,
'
/get_trace_list
'
,
CallChainController
.
getTraceList
],
[
'
get
'
,
'
/get_trace_detail
'
,
CallChainController
.
getTraceDetailList
,
{
id
:
'
notEmpty
'
}],
[
'
get
'
,
'
/get_topo
'
,
CallChainController
.
getTopo
,
{
serviceName
:
'
notEmpty
'
,
start
:
'
notEmpty
'
,
end
:
'
notEmpty
'
}],
//授权管理
[
'
get
'
,
'
/get_tokens
'
,
TokenController
.
getTokens
,
{
application
:
'
notEmpty
'
,
server_name
:
'
notEmpty
'
,}],
//与磐石系统联动而封装的接口
[
'
get
'
,
'
/batch_undeploy_tars
'
,
PanshiController
.
batchUndeployTars
,
{
application
:
'
notEmpty
'
,
server_name
:
'
notEmpty
'
,}],
];
module
.
exports
=
{
pageConf
,
apiConf
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/service/task/TaskService.js
+
1
-
1
View file @
1cab677e
...
...
@@ -99,7 +99,7 @@ TaskService.addTask = async (params) => {
serial
:
params
.
serial
,
userName
:
params
.
user_name
||
''
};
await
AdminService
.
addTask
(
req
)
.
catch
(
e
=>
{
console
.
error
(
'
[AdminService.addTask]:
'
,
e
)})
;
await
AdminService
.
addTask
(
req
);
return
params
.
task_no
;
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help