Starting worker instance as part of the stack, some changes to how environment handled for worker.
This commit is contained in:
parent
6efea66505
commit
f48b09d378
|
@ -37,7 +37,7 @@ services:
|
|||
PORT: 4003
|
||||
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
|
||||
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
|
||||
RAW_MINIO_URL: http://minio-service:9000
|
||||
MINIO_URL: http://minio-service:9000
|
||||
COUCH_DB_USERNAME: ${COUCH_DB_USER}
|
||||
COUCH_DB_PASSWORD: ${COUCH_DB_PASSWORD}
|
||||
COUCH_DB_URL: http://${COUCH_DB_USER}:${COUCH_DB_PASSWORD}@couchdb-service:5984
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "@budibase/deployment",
|
||||
"name": "@budibase/worker",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "0.8.9",
|
||||
"description": "Budibase Deployment Server",
|
||||
|
@ -12,13 +12,16 @@
|
|||
"budibase"
|
||||
],
|
||||
"scripts": {
|
||||
"run:docker": "node src/index.js"
|
||||
"run:docker": "node src/index.js",
|
||||
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
||||
"dev:builder": "npm run dev:stack:init && nodemon src/index.js"
|
||||
},
|
||||
"author": "Budibase",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"@koa/router": "^8.0.0",
|
||||
"aws-sdk": "^2.811.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"got": "^11.8.1",
|
||||
"joi": "^17.2.1",
|
||||
"koa": "^2.7.0",
|
||||
|
@ -33,5 +36,8 @@
|
|||
"pouchdb": "^7.2.2",
|
||||
"pouchdb-all-dbs": "^1.0.2",
|
||||
"server-destroy": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env node
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
|
||||
async function init() {
|
||||
const envFilePath = path.join(process.cwd(), ".env")
|
||||
if (fs.existsSync(envFilePath)) {
|
||||
return
|
||||
}
|
||||
const envFileJson = {
|
||||
SELF_HOSTED: 1,
|
||||
PORT: 4002,
|
||||
MINIO_ACCESS_KEY: "budibase",
|
||||
MINIO_SECRET_KEY: "budibase",
|
||||
COUCH_DB_USER: "budibase",
|
||||
COUCH_DB_PASSWORD: "budibase",
|
||||
MINIO_URL: "http://localhost:10000/",
|
||||
COUCH_DB_URL: "http://budibase:budibase@localhost:10000/db/",
|
||||
}
|
||||
let envFile = ""
|
||||
Object.keys(envFileJson).forEach(key => {
|
||||
envFile += `${key}=${envFileJson[key]}\n`
|
||||
})
|
||||
fs.writeFileSync(envFilePath, envFile)
|
||||
}
|
||||
|
||||
// if more than init required use this to determine the command type
|
||||
//const managementCommand = process.argv.slice(2)[0]
|
||||
|
||||
// for now only one command
|
||||
let command = init
|
||||
|
||||
command()
|
||||
.then(() => {
|
||||
console.log("Done! 🎉")
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(
|
||||
"Something went wrong while managing budibase dev worker:",
|
||||
err.message
|
||||
)
|
||||
})
|
|
@ -43,7 +43,7 @@ async function getMinioSession() {
|
|||
|
||||
// make sure the bucket exists
|
||||
const objClient = new AWS.S3({
|
||||
endpoint: env.RAW_MINIO_URL,
|
||||
endpoint: env.MINIO_URL,
|
||||
region: REGION,
|
||||
s3ForcePathStyle: true, // needed with minio?
|
||||
params: {
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
function isDev() {
|
||||
return process.env.NODE_ENV !== "production"
|
||||
}
|
||||
|
||||
let LOADED = false
|
||||
if (!LOADED && isDev()) {
|
||||
require("dotenv").config()
|
||||
LOADED = true
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SELF_HOSTED: process.env.SELF_HOSTED,
|
||||
PORT: process.env.PORT,
|
||||
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
||||
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
||||
RAW_MINIO_URL: process.env.RAW_MINIO_URL,
|
||||
MINIO_PORT: process.env.MINIO_PORT,
|
||||
MINIO_URL: process.env.MINIO_URL,
|
||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||
LOG_LEVEL: process.env.LOG_LEVEL,
|
||||
/* TODO: to remove - once deployment removed */
|
||||
SELF_HOST_KEY: process.env.SELF_HOST_KEY,
|
||||
COUCH_DB_USERNAME: process.env.COUCH_DB_USERNAME,
|
||||
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||
_set(key, value) {
|
||||
process.env[key] = value
|
||||
module.exports[key] = value
|
||||
},
|
||||
isDev,
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ destroyable(server)
|
|||
|
||||
server.on("close", () => console.log("Server Closed"))
|
||||
|
||||
module.exports = server.listen(env.PORT || 4002, async () => {
|
||||
module.exports = server.listen(parseInt(env.PORT || 4002), async () => {
|
||||
console.log(`Worker running on ${JSON.stringify(server.address())}`)
|
||||
})
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue