Commit fb0f599f authored by nanahira's avatar nanahira

supportmc

parent 5b412fbd
...@@ -197,6 +197,8 @@ var ZipData = function(msg) { ...@@ -197,6 +197,8 @@ var ZipData = function(msg) {
var StartServer = function(msg) { var StartServer = function(msg) {
if (config.pm2_name) { if (config.pm2_name) {
runcmd("pm2", ["restart", config.pm2_name], ".", "Server Started"); runcmd("pm2", ["restart", config.pm2_name], ".", "Server Started");
} else if (config.minecraft_id) {
runcmd("pm2", ["restart", config.minecraft_id], ".", "Minecraft Server Started");
} else { } else {
sendResponse("Permission denied"); sendResponse("Permission denied");
} }
...@@ -204,6 +206,8 @@ var StartServer = function(msg) { ...@@ -204,6 +206,8 @@ var StartServer = function(msg) {
var StopServer = function(msg) { var StopServer = function(msg) {
if (config.pm2_name) { if (config.pm2_name) {
runcmd("pm2", ["stop", config.pm2_name], ".", "Server Stopped"); runcmd("pm2", ["stop", config.pm2_name], ".", "Server Stopped");
} else if (config.minecraft_id) {
runcmd("pm2", ["stop", config.minecraft_id], ".", "Minecraft Server Stopped");
} else { } else {
sendResponse("Permission denied"); sendResponse("Permission denied");
} }
...@@ -224,6 +228,13 @@ var RunCommand = function(msg) { ...@@ -224,6 +228,13 @@ var RunCommand = function(msg) {
sendResponse("Permission denied"); sendResponse("Permission denied");
} }
} }
var RunMinecraftCommand = function(msg) {
if (config.minecraft_id) {
runcmd("pm2", ["send", config.minecraft_id, msg], ".", "Finshed Running Minecraft Command");
} else {
sendResponse("Permission denied");
}
}
var pt=config.port; var pt=config.port;
http.createServer(function (req, res) { http.createServer(function (req, res) {
var u = url.parse(req.url, true); var u = url.parse(req.url, true);
...@@ -310,6 +321,11 @@ http.createServer(function (req, res) { ...@@ -310,6 +321,11 @@ http.createServer(function (req, res) {
res.end(u.query.callback+'({"message":"Running Command"});'); res.end(u.query.callback+'({"message":"Running Command"});');
RunCommand(u.query.message); RunCommand(u.query.message);
} }
else if (u.pathname === '/api/run_minecraft_command') {
res.writeHead(200);
res.end(u.query.callback+'({"message":"Running Minecraft Command"});');
RunMinecraftCommand(u.query.message);
}
else { else {
res.writeHead(400); res.writeHead(400);
res.end("400"); res.end("400");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment