feat(bot): Update bot setup script for improved configuration and service management; adjust permissions, enhance logging, and streamline service commands
This commit is contained in:
parent
0558329cb4
commit
a9d9ddac4c
1 changed files with 22 additions and 11 deletions
|
@ -52,33 +52,43 @@ lxc config device add "$PARAM_TENANT"-bot botdata disk source="$HOST_DATA" path=
|
||||||
lxc config device add "$PARAM_TENANT"-bot botconf disk source="$HOST_CONF" path=/opt/gbo/conf
|
lxc config device add "$PARAM_TENANT"-bot botconf disk source="$HOST_CONF" path=/opt/gbo/conf
|
||||||
lxc config device add "$PARAM_TENANT"-bot botlogs disk source="$HOST_LOGS" path=/opt/gbo/logs
|
lxc config device add "$PARAM_TENANT"-bot botlogs disk source="$HOST_LOGS" path=/opt/gbo/logs
|
||||||
|
|
||||||
lxc exec "$PARAM_TENANT"-bot -- bash -c "
|
lxc exec "$PARAM_TENANT"-bot -- bash -c '
|
||||||
mkdir -p /opt/gbo/data /opt/gbo/conf /opt/gbo/logs
|
mkdir -p /opt/gbo/data /opt/gbo/conf /opt/gbo/logs
|
||||||
chown -R bot:bot /opt/gbo/data /opt/gbo/conf /opt/gbo/logs
|
chown -R bot:bot /opt/gbo
|
||||||
|
|
||||||
sudo apt install -y curl gnupg ca-certificates
|
sudo apt update
|
||||||
|
sudo apt install -y curl gnupg ca-certificates git
|
||||||
|
|
||||||
|
# Install Node.js 22.x
|
||||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
|
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
|
||||||
sudo apt install -y nodejs
|
sudo apt install -y nodejs
|
||||||
|
|
||||||
|
# Install Xvfb and other dependencies
|
||||||
|
sudo apt install -y xvfb libgbm-dev
|
||||||
|
|
||||||
|
# Clone and setup bot server
|
||||||
cd /opt/gbo/data
|
cd /opt/gbo/data
|
||||||
git clone https://alm.pragmatismo.com.br/generalbots/botserver.git
|
git clone https://alm.pragmatismo.com.br/generalbots/botserver.git
|
||||||
cd botserver
|
cd botserver
|
||||||
npm i
|
npm install
|
||||||
|
npx puppeteer browsers install chrome
|
||||||
./node_modules/.bin/tsc
|
./node_modules/.bin/tsc
|
||||||
npx puppeteer browsers install
|
|
||||||
|
|
||||||
cat > /etc/systemd/system/bot.service <<EOF
|
# Create systemd service
|
||||||
|
sudo tee /etc/systemd/system/bot.service > /dev/null <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Bot Server
|
Description=Bot Server
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=bot
|
User=bot
|
||||||
Group=root
|
Group=bot
|
||||||
Environment="DISPLAY=:99"
|
Environment="DISPLAY=:99"
|
||||||
ExecStartPre=/bin/bash -c "/usr/bin/Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &"
|
ExecStartPre=/bin/bash -c "/usr/bin/Xvfb :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset &"
|
||||||
WorkingDirectory=/opt/gbo/data/botserver
|
WorkingDirectory=/opt/gbo/data/botserver
|
||||||
ExecStart=/usr/bin/node /opt/gbo/data/botserver/boot.mjs
|
ExecStart=/usr/bin/node /opt/gbo/data/botserver/boot.mjs
|
||||||
Restart=always
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
StandardOutput=append:/opt/gbo/logs/stdout.log
|
StandardOutput=append:/opt/gbo/logs/stdout.log
|
||||||
StandardError=append:/opt/gbo/logs/stderr.log
|
StandardError=append:/opt/gbo/logs/stderr.log
|
||||||
|
|
||||||
|
@ -86,10 +96,11 @@ StandardError=append:/opt/gbo/logs/stderr.log
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl daemon-reload
|
# Reload and start service
|
||||||
systemctl enable bot
|
sudo systemctl daemon-reload
|
||||||
systemctl start bot
|
sudo systemctl enable bot.service
|
||||||
"
|
sudo systemctl start bot.service
|
||||||
|
'
|
||||||
|
|
||||||
lxc config device remove "$PARAM_TENANT"-bot bot-proxy 2>/dev/null || true
|
lxc config device remove "$PARAM_TENANT"-bot bot-proxy 2>/dev/null || true
|
||||||
lxc config device add "$PARAM_TENANT"-bot bot-proxy proxy \
|
lxc config device add "$PARAM_TENANT"-bot bot-proxy proxy \
|
||||||
|
|
Loading…
Add table
Reference in a new issue