mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
update update and reboot
This commit is contained in:
parent
ea83bdaca1
commit
7205108d1f
2 changed files with 25 additions and 31 deletions
|
@ -1,35 +1,29 @@
|
|||
const { createEmbed } = require('#utils/embed')
|
||||
const { editOrReply } = require('#utils/message')
|
||||
|
||||
const superagent = require('superagent')
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
module.exports = {
|
||||
name: "deploy",
|
||||
name: "reboot",
|
||||
label: "flags",
|
||||
metadata: {
|
||||
description: `Queries pb manager to trigger a deploy and restart flow`,
|
||||
description_short: '[MANAGER] Query deploy',
|
||||
examples: ['deploy'],
|
||||
description: `Reboot the bot.`,
|
||||
description_short: 'Reboot the bot.',
|
||||
examples: ['reboot'],
|
||||
category: 'dev',
|
||||
usage: 'deploy'
|
||||
usage: 'reboot'
|
||||
},
|
||||
onBefore: context => context.user.isClientOwner,
|
||||
onCancel: () => { },
|
||||
run: async (context) => {
|
||||
if (!["production","prod","prodnew"].includes(process.env.environment)) return await editOrReply(context, createEmbed("error", context, "Cannot update on this instance."))
|
||||
await editOrReply(context, createEmbed("loading", context, "Querying deploy..."))
|
||||
|
||||
try {
|
||||
const t = Date.now()
|
||||
|
||||
// Call server to query update
|
||||
await superagent.post(`${process.env.PB_MANAGER_HOST}_pbs/v1/DeployPbService`)
|
||||
.set("Authorization", process.env.PB_MANAGER_KEY)
|
||||
|
||||
return await editOrReply(context, createEmbed("success", context, "Deployment queried at manager. Shutting down."))
|
||||
} catch (e) {
|
||||
try{
|
||||
await editOrReply(context, createEmbed("loading", context, "Updating bot..."));
|
||||
execSync("git pull");
|
||||
await editOrReply(context, createEmbed("success", context, "Rebooting bot..."));
|
||||
execSync("pm2 restart labscore-prd");
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
return await editOrReply(context, createEmbed("error", context, "Manager reported error during deploy query."))
|
||||
await editOrReply(context, createEmbed("error", context, "Unable to reboot."))
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue