mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-21 04:17:03 -04:00
add example env, "improve" selfhostability
This commit is contained in:
parent
99bac88155
commit
07ceaac9d9
5 changed files with 108 additions and 8 deletions
|
@ -129,6 +129,17 @@ commandClient.on('commandDelete', async ({context, reply}) => {
|
|||
|
||||
commandClient.on('commandRunError', async ({context, error}) => {
|
||||
try{
|
||||
// No service configured
|
||||
if(!process.env.MAINTOWER_URL){
|
||||
console.log(error);
|
||||
|
||||
await editOrReply(context, {
|
||||
content: `${icon("cross")} Something went wrong while attempting to run this command. (check console)`
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Log the error via our maintower service
|
||||
let packages = {
|
||||
data: {},
|
||||
|
@ -162,6 +173,17 @@ commandClient.on('commandRunError', async ({context, error}) => {
|
|||
|
||||
interactionClient.on('commandRunError', async ({context, error}) => {
|
||||
try{
|
||||
// No service configured
|
||||
if(!process.env.MAINTOWER_URL){
|
||||
console.error(error ? error.stack || error.message : error);
|
||||
|
||||
await editOrReply(context, {
|
||||
content: `${icon("cross")} Something went wrong while attempting to run this command. (check console)`
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Log the error via our maintower service
|
||||
let packages = {
|
||||
data: {},
|
||||
|
@ -197,6 +219,9 @@ interactionClient.on('commandRunError', async ({context, error}) => {
|
|||
|
||||
// Logging
|
||||
cluster.on(ClientEvents.REST_RESPONSE, async ({response, restRequest, shard}) => {
|
||||
// No service configured
|
||||
if(!process.env.MAINTOWER_URL) return;
|
||||
|
||||
const route = response.request.route;
|
||||
if (route) {
|
||||
if (!response.ok) {
|
||||
|
@ -209,6 +234,7 @@ interactionClient.on('commandRunError', async ({context, error}) => {
|
|||
});
|
||||
|
||||
cluster.on(ClientEvents.WARN, async ({error}) => {
|
||||
if(!process.env.MAINTOWER_URL) { console.warn(error); return; }
|
||||
await basecamp(`<:ico_w2:1086624961025810485>\`[${process.env.HOSTNAME}]\` **\` CLUSTER_WARNING \`** Cluster ${cluster.manager.clusterId} reported warning @ \`${Date.now()}\`:\n\`\`\`${error}\`\`\``)
|
||||
});
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
const superagent = require('superagent')
|
||||
|
||||
const MAINTOWER_BASE_URL = `https://labscore-v2.vercel.app/maintower/`
|
||||
const MAINTOWER_BASE_URL = process.env.MAINTOWER_URL
|
||||
|
||||
let maintowerClient = "1fepg2wdk-prod"
|
||||
if(process.env.MAINTOWER_OVERRIDE) maintowerClient = process.env.MAINTOWER_OVERRIDE
|
||||
|
||||
module.exports.maintower = async function (packages, type){
|
||||
if(!MAINTOWER_BASE_URL) { console.warn("No maintower url configured."); return; }
|
||||
try{
|
||||
let res = await superagent.post(MAINTOWER_BASE_URL + 'invoke')
|
||||
.set({
|
||||
|
@ -26,6 +27,7 @@ module.exports.maintower = async function (packages, type){
|
|||
}
|
||||
|
||||
module.exports.basecamp = async function (log, content = ""){
|
||||
if(!MAINTOWER_BASE_URL) { console.warn("No maintower url configured."); return; }
|
||||
try{
|
||||
let res = await superagent.post(MAINTOWER_BASE_URL + 'basecamp')
|
||||
.set({
|
||||
|
@ -41,6 +43,7 @@ module.exports.basecamp = async function (log, content = ""){
|
|||
}
|
||||
|
||||
module.exports.ingest = async function (event, type = "generic"){
|
||||
if(!process.env.INGEST_SERVICE_HOST) return console.warn("No ingest service host configured.")
|
||||
try{
|
||||
let r = await superagent.get(`${process.env.INGEST_SERVICE_HOST}/d/${type}/${encodeURIComponent(event)}`)
|
||||
.set("x-ingest-client", process.env.INGEST_SERVICE_CLIENT)
|
||||
|
|
|
@ -36,6 +36,8 @@ async function getTestConfig(){
|
|||
}
|
||||
|
||||
async function hasFeature(context, feature){
|
||||
if(!process.env.TESTING_CONFIG_URL) { console.warn("Test service config URL is missing, test features will be disabled."); return false; };
|
||||
|
||||
// We need to load the test config first
|
||||
if(TESTING_REVISION == "-1") await getTestConfig();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue