Skip to content
Snippets Groups Projects
Commit d034968b authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira
Browse files

Merge branch 'issue/51' into 'master'

Issue#51: Add service generator to BlendDB

See merge request !44
parents 1f78b1b3 cbd93eaf
No related branches found
No related tags found
1 merge request!44Issue#51: Add service generator to BlendDB
Pipeline #
...@@ -16,3 +16,4 @@ ...@@ -16,3 +16,4 @@
/build /build
/dist /dist
/database/views /database/views
/service
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
"test": "ts-node node_modules/istanbul/lib/cli.js cover -x \"**/*.spec.ts\" -e .ts _mocha", "test": "ts-node node_modules/istanbul/lib/cli.js cover -x \"**/*.spec.ts\" -e .ts _mocha",
"show-coverage": "xdg-open coverage/lcov-report/index.html", "show-coverage": "xdg-open coverage/lcov-report/index.html",
"doc-api": "raml2html -i specs/blendb-api-v1.raml -o doc/api-v1-reference.html", "doc-api": "raml2html -i specs/blendb-api-v1.raml -o doc/api-v1-reference.html",
"database": "ts-node database/config.ts database" "database": "ts-node database/config.ts database",
"service": "./scripts/service.sh"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
#! /bin/bash
#HUGE work around to make this script allways execute at his location in dir struct
basePath=$(echo $BASH_SOURCE | rev | cut -c 11- | rev)
cd $basePath/..
mkdir -p service
WORKSPACE=$(pwd)
REAL_USER=$USER
BLENDB_PORT=3001
if [[ $1 != "" ]]; then
BLENDB_PORT=$1
fi
if [[ $2 != "" ]]; then
REAL_USER=$2
fi
cd service
echo "[Unit]" > blendb.service
echo "Description=BlenDB API" >> blendb.service
echo "After=network.target" >> blendb.service
echo "" > blendb.service
echo "[Service]" >> blendb.service
echo "User=$REAL_USER" >> blendb.service
echo "WorkingDirectory=$WORKSPACE" >> blendb.service
echo "ExecStart=$WORKSPACE/service/service.sh" >> blendb.service
echo "" >> blendb.service
echo "[Install]" >> blendb.service
echo "WantedBy=multi-user.target" >> blendb.service
echo "#! /bin/bash" > service.sh
USING_NVM="false"
VERSION=$(node --version)
error=$(source $NVM_DIR/nvm.sh)
if [[ $? -eq 0 ]]; then
source $NVM_DIR/nvm.sh
echo "source $NVM_DIR/nvm.sh" >> service.sh
echo "nvm use $VERSION" >> service.sh
USING_NVM="true"
else
echo "nvm not found, using native node version"
echo ""
fi
echo "PORT=$BLENDB_PORT npm start" >> service.sh
chmod +x service.sh
echo "The service files were created with this parameters"
echo "User that runs the service: $REAL_USER"
echo "PORT: $BLENDB_PORT"
echo "Blendb home dir (WORKSPACE): $WORKSPACE"
echo "Node Version: $VERSION"
echo "Using NVM: $USING_NVM"
echo ""
echo "Node version is get using 'node --version, use nvm to change it"
echo "To set different user and port use npm run service -- <port> [<user>]"
echo "Run this commands, as root (or sudo) to finish the process and start blendb"
SYSTEMD_PATH=/etc/systemd/system/blendb.service
echo -n "rm -f $SYSTEMD_PATH && "
echo -n "ln -s $WORKSPACE/service/blendb.service $SYSTEMD_PATH && "
echo "systemctl daemon-reload && systemctl restart blendb.service"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment