dashboard-core/theme/dbd-soft-ui/pages/admin/control.js

24 lines
782 B
JavaScript
Raw Normal View History

2023-06-19 14:21:58 +05:00
module.exports = {
2023-06-22 19:36:52 +05:00
page: "/control",
// eslint-disable-next-line no-unused-vars
execute: async (req, res, app, config, themeConfig, info) => {
const { uuid, action } = req.query;
if (!uuid && action && req.query.type) {
return res.redirect("/admin?result=true");
}
if (!uuid || !action) return res.sendStatus(412);
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
try {
if (action === "start") await themeConfig.nodeactyl.startServer(uuid);
if (action === "restart") await themeConfig.nodeactyl.restartServer(uuid);
if (action === "stop") await themeConfig.nodeactyl.stopServer(uuid);
if (action === "kill") await themeConfig.nodeactyl.killServer(uuid);
} catch (error) {
console.error(error);
return res.redirect("/admin?result=false");
}
return res.redirect("/admin?result=true");
}
};