Commit 16886594 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Fix start/stop bash scripts

parent c76a219a
Pipeline #4298 failed
......@@ -269,6 +269,7 @@ public class PluginInit extends AbstractLifecycleComponent<PluginInit> {
// Index peers (and listen if new peer appear)
if (pluginSettings.enableBlockchainPeerIndexation()) {
logger.info(String.format("[%s] Indexing blockchain peers...", currencyName));
injector.getInstance(PeerService.class)
.listenAndIndexPeers(peer);
}
......
......@@ -2,6 +2,7 @@
CURRENCY=g1
# Get PID
PID=`ps -efl | grep cesium-plus-pod | grep ${CURRENCY}/lib | awk '/^([0-9]+) ([^\s]) ([a-zA-Z0-9]+) ([0-9]+).*/ {printf "%s", $4}'`
if [[ "$PID" != "" ]];
......@@ -9,9 +10,14 @@ then
echo "Error: Cesium+ pod already started!"
exit -1
else
# Limit JVM heap size
ES_JAVA_OPTS="$ES_JAVA_OPTS -Xmx2g"
export ES_JAVA_OPTS
cd /opt/cesium-plus-pod-${CURRENCY}/bin
./elasticsearch -d
echo "Cesium+ pod started on ${CURRENCY} currency !"
echo "...to follow log: tail -f /opt/cesium-plus-pod-${CURRENCY}/logs/g1-es-data.log"
echo "...to follow log: tail -f /opt/cesium-plus-pod-${CURRENCY}/logs/${CURRENCY}-es-data.log"
fi
......@@ -2,13 +2,13 @@
CURRENCY=g1
# Get ES PID
# Get PID
PID=`ps -efl | grep cesium-plus-pod | grep ${CURRENCY}/lib | awk '{printf "%s", $4}'`
if [[ "$PID" != "" ]];
then
echo "Stopping Cesium+ Pod running on PID $PID..."
sudo kill -15 $PID
echo "Stopping Cesium+ Pod ${CURRENCY} running on PID $PID..."
sudo kill -15 ${PID}
sleep 5s
......@@ -22,13 +22,13 @@ then
PID=`ps -efl | grep cesium-plus-pod | grep ${CURRENCY}/lib | awk '{printf "%s", $4}'`
if [[ "$PID" != "" ]];
then
echo "Error: Unable to stop Cesium+ Pod !"
echo "Error: Unable to stop Cesium+ Pod ${CURRENCY} !"
exit -1
else
echo "Cesium+ Pod stopped"
echo "Cesium+ Pod ${CURRENCY} stopped"
fi
else
echo "Cesium+ Pod not running!"
echo "Cesium+ Pod ${CURRENCY} not running!"
fi
......@@ -6,7 +6,7 @@ ASSET_BASENAME=cesium-plus-pod
ASSET=${ASSET_BASENAME}-${VERSION}-standalone
CURRENCY=g1
REPO=duniter/cesium-plus-pod
ASSET_ZIP_URL=https://github.com/${REPO}/releases/download/v${VERSION}/${ASSET}.zip
ASSET_ZIP_URL=https://github.com/${REPO}/releases/download/${ASSET_BASENAME}-${VERSION}/${ASSET}.zip
if [[ "${VERSION}" == "" ]]; then
echo "ERROR: Missing version argument !"
......@@ -39,7 +39,8 @@ if [[ -x "$READLINK" ]]; then
fi
export BASEDIR=`dirname "$SCRIPT_LOCATION"`
cd $BASEDIR
cd $BASEDIR
BASEDIR=`pwd`
echo "--- Downloading ${ASSET} ... ----------------------"
......@@ -74,20 +75,36 @@ mv ${ASSET_BASENAME}-${VERSION} ${ASSET_BASENAME}-${VERSION}-${CURRENCY}
sudo mv ${ASSET_BASENAME}-${VERSION}-${CURRENCY} /opt/
sudo rm /opt/${ASSET_BASENAME}-${CURRENCY}
sudo ln -s /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY} /opt/${ASSET_BASENAME}-${CURRENCY}
mkdir /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}/data
mv /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}/config/elasticsearch.yml /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}/config/elasticsearch.yml.ori
stop-cesium-plus-pod.sh
# Creating data + log directories
mkdir -p ${BASEDIR}/data
mkdir -p ${BASEDIR}/logs
mkdir -p ${BASEDIR}/backup
cd /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}
ln -s ${BASEDIR}/data data
ln -s ${BASEDIR}/logs logs
cd ${BASEDIR}
./stop-cesium-plus-pod.sh
if [[ "$OLD_VERSION" != "$VERSION" ]];
then
echo "--- Restoring files (data+config) from previous version $OLD_VERSION... ---------------------"
tar -cvf /opt/${ASSET_BASENAME}-${OLD_VERSION}-${CURRENCY}/data/save.tar.gz /opt/${ASSET_BASENAME}-${OLD_VERSION}-${CURRENCY}/data/${CURRENCY}-*
mv /opt/${ASSET_BASENAME}-${OLD_VERSION}-${CURRENCY}/data/${CURRENCY}-* /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}/data
echo "--- Removing symbolic links from previous version $OLD_VERSION... ---------------------"
cp /opt/${ASSET_BASENAME}-${OLD_VERSION}-${CURRENCY}
rm data
rm logs
echo "--- Restoring config file from previous version $OLD_VERSION... ---------------------"
cp /opt/${ASSET_BASENAME}-${OLD_VERSION}-${CURRENCY}/config/elasticsearch.yml /opt/${ASSET_BASENAME}-${VERSION}-${CURRENCY}/config
echo "--- Creating backup file with data... ---------------------"
cd ${BASEDIR}/data
DATE=`date +"%F-%H%M"`
tar -cvf ${BASEDIR}/backup/${CURRENCY}-${DATE}.tar.gz ${CURRENCY}-*
fi
cd ${BASEDIR}
#./start-es-nodes.sh
echo "--- Successfully installed ${ASSET_BASENAME} v$VERSION ! -------------"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment