mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 02:19:25 +08:00
update
This commit is contained in:
@@ -271,6 +271,28 @@ def dockerStopCon():
|
||||
return mw.returnJson(False, '停止失败!' + str(ex))
|
||||
|
||||
|
||||
def dockerExec():
|
||||
# 容器执行命令
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['Hostname'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
Hostname = args['Hostname']
|
||||
|
||||
debug_path = 'data/debug.pl'
|
||||
if os.path.exists(debug_path):
|
||||
return mw.returnJson(False, '开发模式不能进入!')
|
||||
|
||||
c = getDClient()
|
||||
try:
|
||||
conFind = c.containers.get(Hostname)
|
||||
cmd = 'docker container exec -it %s /bin/bash' % Hostname
|
||||
return mw.returnJson(True, cmd)
|
||||
except docker.errors.APIError as ex:
|
||||
return mw.returnJson(False, '连接失败!')
|
||||
|
||||
|
||||
def imageList():
|
||||
imageList = []
|
||||
c = getDClient()
|
||||
@@ -470,6 +492,8 @@ if __name__ == "__main__":
|
||||
print(dockerRunCon())
|
||||
elif func == 'docker_stop_con':
|
||||
print(dockerStopCon())
|
||||
elif func == 'docker_exec':
|
||||
print(dockerExec())
|
||||
elif func == 'image_list':
|
||||
print(imageListData())
|
||||
elif func == 'docker_remove_image':
|
||||
|
||||
@@ -117,6 +117,31 @@ function stopCon(Hostname){
|
||||
});
|
||||
}
|
||||
|
||||
function execCon(Hostname){
|
||||
webShell();
|
||||
var pdata_socket = {};
|
||||
var shell = setInterval(function(){
|
||||
if($('.term-box').length == 0){
|
||||
pdata_socket['data'] = 'exit\n';
|
||||
socket.emit('webssh',pdata_socket);
|
||||
setTimeout(function(){socket.emit('webssh',pdata_socket['data']);},1000);
|
||||
clearInterval(shell);
|
||||
}
|
||||
},500);
|
||||
setTimeout(function(){
|
||||
dPost('docker_exec','',{Hostname:Hostname},function(res){
|
||||
var res = $.parseJSON(res.data);
|
||||
if(!res.status){
|
||||
layer.msg(res.msg,{icon:res.status?1:2});
|
||||
}else{
|
||||
pdata_socket['data'] = 'clear && ' + res.msg +'\n'
|
||||
socket.emit('webssh',pdata_socket);
|
||||
setTimeout(function(){socket.emit('webssh',pdata_socket['data']);},1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function dockerConListRender(){
|
||||
dPost('con_list', '', {}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
@@ -139,7 +164,7 @@ function dockerConListRender(){
|
||||
}
|
||||
|
||||
var op = '';
|
||||
op += '<a href="javascript:;" onclick="pullImages(\''+rlist[i]['RepoTags']+'\',\''+rlist[i]['Id']+'\')" class="btlink">终端</a> | ';
|
||||
op += '<a href="javascript:;" onclick="execCon(\''+rlist[i]['Config']['Hostname']+'\')" class="btlink">终端</a> | ';
|
||||
op += '<a href="javascript:;" onclick="logsCon(\''+rlist[i]['Id']+'\')" class="btlink">日志</a> | ';
|
||||
op += '<a href="javascript:;" onclick="deleteCon(\''+rlist[i]['Config']['Hostname']+'\')" class="btlink">删除</a>';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user