✨ add start/stop/restart feature on containers
This commit is contained in:
@@ -29,11 +29,39 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||
});
|
||||
}
|
||||
});
|
||||
if (action === 'restart') {
|
||||
await container.restart();
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
});
|
||||
|
||||
switch (action) {
|
||||
case 'start':
|
||||
container.start((err, data) => {
|
||||
if (err) {
|
||||
res.status(500).json({
|
||||
message: err,
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'stop':
|
||||
container.stop((err, data) => {
|
||||
if (err) {
|
||||
res.status(500).json({
|
||||
message: err,
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'restart':
|
||||
container.restart((err, data) => {
|
||||
if (err) {
|
||||
res.status(500).json({
|
||||
message: err,
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(400).json({
|
||||
message: 'Invalid action',
|
||||
});
|
||||
}
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user