mirror of
https://github.com/chenasraf/venom.git
synced 2026-05-17 17:28:08 +00:00
feat: improve deployment
This commit is contained in:
@@ -13,7 +13,12 @@ export DISCORD_TOKEN=
|
|||||||
|
|
||||||
# mongodb
|
# mongodb
|
||||||
export MONGODB_URI=mongodb://localhost:27017
|
export MONGODB_URI=mongodb://localhost:27017
|
||||||
export MONGODB_VOLUME_PATH=data/db
|
|
||||||
|
# deployment
|
||||||
|
# where the bot code is located (root folder - absolute path)
|
||||||
|
export APP_ROOT=
|
||||||
|
# where the DB data is saved - absolute path, or relative to APP_ROOT
|
||||||
|
export DB_PATH=data
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
export LOG_LEVEL=debug
|
export LOG_LEVEL=debug
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -131,7 +131,6 @@ dist
|
|||||||
|
|
||||||
# CUSTOM
|
# CUSTOM
|
||||||
src/scripts/outputs
|
src/scripts/outputs
|
||||||
data/brain.dat
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
build
|
build
|
||||||
data/db
|
data/
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ export default [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ignores: ['node_modules/', 'build/', 'dist/', 'gen/'],
|
ignores: ['node_modules/', 'build/', 'dist/', 'gen/', 'scaffold.config.js'],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Description=Venom Bot
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
WorkingDirectory=/root/apps/venom
|
WorkingDirectory={{appRoot}}
|
||||||
ExecStart=/usr/local/bin/pnpm start
|
ExecStart=/usr/local/bin/pnpm start
|
||||||
ExecStop=/bin/kill -SIGINT $MAINPID
|
ExecStop=/bin/kill -SIGINT $MAINPID
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ After=docker.service
|
|||||||
Requires=docker.service
|
Requires=docker.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
WorkingDirectory={{appRoot}}
|
||||||
Environment="DOCKER_RUN_CMD=docker run \
|
Environment="DOCKER_RUN_CMD=docker run \
|
||||||
--name venom-mongo \
|
--name venom-mongo \
|
||||||
--hostname=2d2cb1232ad1 \
|
--hostname=2d2cb1232ad1 \
|
||||||
@@ -16,8 +17,8 @@ Environment="DOCKER_RUN_CMD=docker run \
|
|||||||
--env=MONGO_MAJOR=7.0 \
|
--env=MONGO_MAJOR=7.0 \
|
||||||
--env=MONGO_VERSION=7.0.12 \
|
--env=MONGO_VERSION=7.0.12 \
|
||||||
--env=HOME=/data/db \
|
--env=HOME=/data/db \
|
||||||
--volume=./data/db:{{dbPath}}/db \
|
--volume=./{{dbPath}}/db:/data/db \
|
||||||
--volume=./data/configdb:/{{dbPath}}/configdb \
|
--volume=./{{dbPath}}/configdb:/data/configdb \
|
||||||
--volume=./data/configdb \
|
--volume=./data/configdb \
|
||||||
--volume=/data/db \
|
--volume=/data/db \
|
||||||
--network=bridge -p 27017:27017 \
|
--network=bridge -p 27017:27017 \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"logs": "journalctl -f -u venom-bot.service",
|
"logs": "journalctl -f -u venom-bot.service",
|
||||||
"build": "tsc && tsc-alias",
|
"build": "tsc && tsc-alias",
|
||||||
"gen": "simple-scaffold -c scaffold.config.js -k",
|
"gen": "simple-scaffold -c scaffold.config.js -k",
|
||||||
"install-services": "scripts/install-services.zsh",
|
"install-services": "src/scripts/install-services.zsh",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
const path = require('node:path')
|
||||||
|
const dotenv = require('dotenv')
|
||||||
|
|
||||||
|
dotenv.config({ path: path.resolve(process.cwd(), '.env.local') })
|
||||||
|
dotenv.config({ path: path.resolve(process.cwd(), '.env') })
|
||||||
|
|
||||||
|
console.log(process.env)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
command: {
|
command: {
|
||||||
templates: ['gen/command'],
|
templates: ['gen/command'],
|
||||||
@@ -11,8 +19,9 @@ module.exports = {
|
|||||||
templates: ['gen/services'],
|
templates: ['gen/services'],
|
||||||
subdir: false,
|
subdir: false,
|
||||||
data: {
|
data: {
|
||||||
// eslint-disable-next-line no-undef
|
dbPath: process.env.DB_PATH,
|
||||||
dbPath: process.env.MONGODB_VOLUME_PATH,
|
appRoot: process.env.APP_ROOT,
|
||||||
},
|
},
|
||||||
|
name: '-',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/scripts/install-services.zsh
Normal file → Executable file
12
src/scripts/install-services.zsh
Normal file → Executable file
@@ -1,11 +1,23 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
if [[ "$1" == "--dry-run" || "$1" == "-d" ]]; then
|
||||||
|
dry=1
|
||||||
|
fi
|
||||||
|
|
||||||
echo 'Installing dependencies...'
|
echo 'Installing dependencies...'
|
||||||
pnpm install
|
pnpm install
|
||||||
tmp=$(mktemp -d)
|
tmp=$(mktemp -d)
|
||||||
echo 'Generating systemd services...'
|
echo 'Generating systemd services...'
|
||||||
pnpm simple-scaffold -c scaffold.config.js -k services -o $tmp
|
pnpm simple-scaffold -c scaffold.config.js -k services -o $tmp
|
||||||
echo 'Installing systemd services...'
|
echo 'Installing systemd services...'
|
||||||
|
|
||||||
|
if [[ $dry -eq 1 ]]; then
|
||||||
|
echo 'Dry run. Exiting'
|
||||||
|
echo
|
||||||
|
tail -n +1 $tmp/*
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
sudo mv $tmp/* /etc/systemd/system/
|
sudo mv $tmp/* /etc/systemd/system/
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable venom-bot
|
systemctl enable venom-bot
|
||||||
|
|||||||
Reference in New Issue
Block a user