Merge pull request #5 from jstefanop/dev-BTC

Merge 0.3.1 updates to production
This commit is contained in:
jstefanop 2021-07-25 20:15:50 -04:00 committed by GitHub
commit e406a0baf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 78 additions and 20 deletions

1
.gitignore vendored
View File

@ -66,3 +66,4 @@ typings/
#backed
backend/apollo-miner/apollo-miner.*
backend/apollo-miner/*config*
backend/apollo-miner/miner.events

@ -1 +1 @@
Subproject commit 1d6eb6b862f9ed6fdbbd7c6d9f1c6f357e631b3c
Subproject commit c0d56f4c4d3eafdf01a8499ddff32d0fcb19506e

View File

@ -10,6 +10,9 @@ ExecStart=/opt/apolloapi/backend/apollo-miner/miner_start.sh
WorkingDirectory=/opt/apolloapi/backend/apollo-miner
#Stop:
ExecStop=/opt/apolloapi/backend/apollo-miner/miner_stop.sh
#Restart
Restart=always
RestartSec=30s
[Install]
WantedBy=multi-user.target

View File

@ -1,3 +1,10 @@
#!/bin/bash
screen -dmS node /opt/apolloapi/backend/node/bitcoind -datadir=/media/nvme/Bitcoin -conf=/opt/apolloapi/backend/node/bitcoin.conf
DEVICE=/dev/nvme0n1p1
if [ -b "$DEVICE" ]; then
screen -dmS node /opt/apolloapi/backend/node/bitcoind -datadir=/media/nvme/Bitcoin -conf=/opt/apolloapi/backend/node/bitcoin.conf
else
exit 0
fi

View File

@ -60,17 +60,6 @@ yarn build
echo "80" > $TMPFILE
### SYSTEMD ###
echo -e "${YELLOW} ---> Updating systemd files${NC}"
echo -e "${YELLOW} ---> Running update_system script${NC}"
cp $APOLLO_DIR/backend/apollo-ui.service /etc/systemd/system/
cp $APOLLO_DIR/backend/apollo-miner.service /etc/systemd/system/
cp $APOLLO_DIR/backend/node.service /etc/systemd/system/
echo -e "${YELLOW} ---> Reloading systemd${NC}"
systemctl daemon-reload
echo "100" > $TMPFILE
echo -e "${YELLOW} ---> Restarting APP${NC}"
systemctl restart apollo-ui
bash $APOLLO_DIR/backend/update_system

0
backend/update.fake Normal file → Executable file
View File

30
backend/update_system Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
TMPFILE='/tmp/update_progress'
APOLLO_DIR=/opt/apolloapi
### SYSTEM commands ###
# Write down this line the system commands needed
# Don't touch below this line
echo "90" > $TMPFILE
### SYSTEMD ###
echo -e "${YELLOW} ---> Updating systemd files${NC}"
cp $APOLLO_DIR/backend/apollo-ui.service /etc/systemd/system/
cp $APOLLO_DIR/backend/apollo-miner.service /etc/systemd/system/
cp $APOLLO_DIR/backend/node.service /etc/systemd/system/
echo -e "${YELLOW} ---> Reloading systemd${NC}"
systemctl daemon-reload
echo "100" > $TMPFILE
echo -e "${YELLOW} ---> Restarting APP${NC}"
systemctl restart apollo-ui
systemctl restart node
systemctl restart apollo-miner

View File

@ -0,0 +1,18 @@
module.exports.typeDefs = `
type McuActions {
version: McuAppVersionOutput!
}
type McuAppVersionOutput {
result: String
error: Error
}
`
module.exports.resolvers = {
McuActions: {
version (root, args, { dispatch }) {
return dispatch('api/mcu/version')
}
}
}

View File

@ -13,7 +13,6 @@ module.exports.typeDefs = `
}
type McuStats {
currentAppVersion: String,
timestamp: String!
hostname: String,
operatingSystem: String

View File

@ -0,0 +1,13 @@
const { join } = require('path')
const { exec } = require('child_process')
const axios = require('axios')
module.exports = ({ define }) => {
define('version', async (payload, { knex, errors, utils }) => {
const gitAppVersion = await axios.get('https://raw.githubusercontent.com/jstefanop/apolloui/production-BTC/package.json');
const currentAppVersion = (gitAppVersion && gitAppVersion.data) ? gitAppVersion.data.version : null;
return currentAppVersion
}, {
auth: true
})
}

View File

@ -2,7 +2,7 @@ const { exec } = require('child_process')
module.exports = ({ define }) => {
define('reboot', async (payload, { knex, errors, utils }) => {
if (process.env.NODE_ENV === 'production') return exec('/etc/system_reboot.sh');
if (process.env.NODE_ENV === 'production') return exec('sudo reboot');
return;
}, {
auth: true

View File

@ -2,7 +2,7 @@ const { exec } = require('child_process')
module.exports = ({ define }) => {
define('shutdown', async (payload, { knex, errors, utils }) => {
if (process.env.NODE_ENV === 'production') return exec('/etc/system_shutdown.sh')
if (process.env.NODE_ENV === 'production') return exec('sudo shutdown -h now')
return;
}, {
auth: true

View File

@ -5,8 +5,6 @@ const axios = require('axios')
module.exports = ({ define }) => {
define('stats', async (payload, { knex, errors, utils }) => {
const stats = await getOsStats()
const gitAppVersion = await axios.get('https://raw.githubusercontent.com/jstefanop/apolloui/production-BTC/package.json');
stats.currentAppVersion = (gitAppVersion && gitAppVersion.data) ? gitAppVersion.data.version : null;
stats.timestamp = new Date().toISOString()
return { stats }
}, {