mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 04:43:57 +00:00
feat: kill db process
This commit is contained in:
@@ -274,6 +274,20 @@ module.exports = {
|
|||||||
return this.loadDataCore('serverSummary', { conid });
|
return this.loadDataCore('serverSummary', { conid });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
killDatabaseProcess_meta: true,
|
||||||
|
async killDatabaseProcess(ctx, req) {
|
||||||
|
const { conid, pid } = ctx;
|
||||||
|
testConnectionPermission(conid, req);
|
||||||
|
|
||||||
|
const opened = await this.ensureOpened(conid);
|
||||||
|
if (!opened) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (opened.connection.isReadOnly) return false;
|
||||||
|
|
||||||
|
return this.sendRequest(opened, { msgtype: 'killDatabaseProcess', pid });
|
||||||
|
},
|
||||||
|
|
||||||
summaryCommand_meta: true,
|
summaryCommand_meta: true,
|
||||||
async summaryCommand({ conid, command, row }, req) {
|
async summaryCommand({ conid, command, row }, req) {
|
||||||
testConnectionPermission(conid, req);
|
testConnectionPermission(conid, req);
|
||||||
|
|||||||
@@ -146,6 +146,18 @@ async function handleServerSummary({ msgid }) {
|
|||||||
return handleDriverDataCore(msgid, driver => driver.serverSummary(dbhan));
|
return handleDriverDataCore(msgid, driver => driver.serverSummary(dbhan));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleKillDatabaseProccess({ msgid, pid }) {
|
||||||
|
await waitConnected();
|
||||||
|
const driver = requireEngineDriver(storedConnection);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await driver.killProcess(dbhan, Number(pid));
|
||||||
|
process.send({ msgtype: 'response', msgid, result });
|
||||||
|
} catch (err) {
|
||||||
|
process.send({ msgtype: 'response', msgid, errorMessage: err.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleSummaryCommand({ msgid, command, row }) {
|
async function handleSummaryCommand({ msgid, command, row }) {
|
||||||
return handleDriverDataCore(msgid, driver => driver.summaryCommand(dbhan, command, row));
|
return handleDriverDataCore(msgid, driver => driver.summaryCommand(dbhan, command, row));
|
||||||
}
|
}
|
||||||
@@ -154,6 +166,7 @@ const messageHandlers = {
|
|||||||
connect: handleConnect,
|
connect: handleConnect,
|
||||||
ping: handlePing,
|
ping: handlePing,
|
||||||
serverSummary: handleServerSummary,
|
serverSummary: handleServerSummary,
|
||||||
|
killDatabaseProcess: handleKillDatabaseProccess,
|
||||||
summaryCommand: handleSummaryCommand,
|
summaryCommand: handleSummaryCommand,
|
||||||
createDatabase: props => handleDatabaseOp('createDatabase', props),
|
createDatabase: props => handleDatabaseOp('createDatabase', props),
|
||||||
dropDatabase: props => handleDatabaseOp('dropDatabase', props),
|
dropDatabase: props => handleDatabaseOp('dropDatabase', props),
|
||||||
|
|||||||
@@ -3,12 +3,22 @@
|
|||||||
import TableControl from '../elements/TableControl.svelte';
|
import TableControl from '../elements/TableControl.svelte';
|
||||||
import { _t } from '../translations';
|
import { _t } from '../translations';
|
||||||
import CtaButton from '../buttons/CtaButton.svelte';
|
import CtaButton from '../buttons/CtaButton.svelte';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
|
import runCommand from '../commands/runCommand';
|
||||||
|
|
||||||
|
export let conid;
|
||||||
export let processes: DatabaseProcess[] = [];
|
export let processes: DatabaseProcess[] = [];
|
||||||
|
|
||||||
async function killProcess(processId: string) {
|
async function killProcess(processId: number) {
|
||||||
// TODO: Implement kill process functionality
|
// TODO: Implement kill process functionality
|
||||||
console.log('Kill process:', processId);
|
console.log('Kill process:', processId);
|
||||||
|
|
||||||
|
await apiCall('server-connections/kill-database-process', {
|
||||||
|
pid: processId,
|
||||||
|
conid,
|
||||||
|
});
|
||||||
|
|
||||||
|
runCommand('serverSummary.refresh');
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatRunningTime(seconds: number): string {
|
function formatRunningTime(seconds: number): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user