From e3683c4abdd6abb055eee83b6d412c2dcf1ac8ff Mon Sep 17 00:00:00 2001 From: jfederico Date: Thu, 20 Feb 2020 14:49:26 -0500 Subject: Added auto-start updated scalite-run.service fixed auto-deployer.service --- README.md | 19 ++++++++++++++----- scripts/deploy.sh | 9 +++++---- scripts/scalelite-auto-deployer.service | 4 ++-- scripts/scalelite-run.service | 18 ++++++++++++++++++ scripts/start.sh | 6 ++++++ scripts/stop.sh | 6 ++++++ 6 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 scripts/scalelite-run.service create mode 100755 scripts/start.sh create mode 100755 scripts/stop.sh diff --git a/README.md b/README.md index 3495c17..99bec7a 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ Note that the application can be run in the background with `docker-compose up - #### 4.1. Initializing pool of servers -Since there are no servers added by default, atleast 1 server must be added and enabled in order to get started. +Since there are no servers added by default, atleast 1 server must be added and enabled in order to get started. Open a new console and get the IDs of the docker containers running: @@ -266,20 +266,29 @@ sudo .scripts/deploy.sh -##### 4.2.2. Automatic updates and auto-start +##### 4.2.2. Automatic updates Use the scripts provided. ``` -sudo ln -s /home/ubuntu/scalelite-run/scripts/deploy.sh /usr/local/bin/scalelite-deploy -sudo cp /home/ubuntu/scalelite-run/scripts/scalelite-auto-deployer.service /etc/systemd/system/scalelite-auto-deployer.service -sudo cp /home/ubuntu/scalelite-run/scripts/scalelite-auto-deployer.timer /etc/systemd/system/scalelite-auto-deployer.timer +sudo ln -s /scalelite-run/scripts/deploy.sh /usr/local/bin/scalelite-deploy +sudo cp /scalelite-run/scripts/scalelite-auto-deployer.service /etc/systemd/system/scalelite-auto-deployer.service +sudo cp /scalelite-run/scripts/scalelite-auto-deployer.timer /etc/systemd/system/scalelite-auto-deployer.timer sudo systemctl daemon-reload sudo systemctl enable scalelite-auto-deployer.service sudo systemctl enable scalelite-auto-deployer.timer sudo systemctl start scalelite-auto-deployer.timer ``` + + +##### 4.2.3. Automatic start + +Use the scripts provided. + +``` +``` + ## II. Distributed Deployment diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 871f11a..bd78599 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,5 +1,6 @@ #!/bin/bash +DIR="$(cd "$(dirname "$0")" && pwd)" STATUS="Status: Downloaded newer image for blindsidenetwks/scalelite:latest" new_status=$(sudo docker pull blindsidenetwks/scalelite:latest | grep Status:) @@ -8,10 +9,10 @@ echo $new_status if [ "$STATUS" == "$new_status" ] then - cd /home/ubuntu/scalelite-run - sudo docker-compose down - sudo docker rmi $(sudo docker images -f dangling=true -q) - sudo docker-compose up -d + cd $DIR/.. + docker-compose down + docker rmi $(docker images -f dangling=true -q) + docker-compose up -d fi exit 0 diff --git a/scripts/scalelite-auto-deployer.service b/scripts/scalelite-auto-deployer.service index 74ae32f..55a70f4 100644 --- a/scripts/scalelite-auto-deployer.service +++ b/scripts/scalelite-auto-deployer.service @@ -2,8 +2,8 @@ Description=ScaleLite Auto Deployer [Service] -ExecStart=/bin/bash /usr/local/bin/scalelite-deploy +ExecStart=/bin/bash /opt/scalelite-run/scripts/deploy.sh [Install] WantedBy=multi-user.target -Alias=scalelite.service +Alias=scalelite-auto-deployer diff --git a/scripts/scalelite-run.service b/scripts/scalelite-run.service new file mode 100644 index 0000000..0d895e1 --- /dev/null +++ b/scripts/scalelite-run.service @@ -0,0 +1,18 @@ +[Unit] +Description=ScaleLite Run +After=network.target +After=systemd-user-sessions.service +After=network-online.target + +[Service] +ExecStart=/bin/bash /opt/scalelite-run/scripts/start.sh +ExecStop=/bin/bash /opt/scalelite-run/scripts/stop.sh +TimeoutSec=30 +Restart=on-failure +RestartSec=30 +StartLimitInterval=350 +StartLimitBurst=10 + +[Install] +WantedBy=multi-user.target +Alias=scalelite-run diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..d320c52 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +DIR="$(cd "$(dirname "$0")" && pwd)" + +cd $DIR/.. +docker-compose up -d diff --git a/scripts/stop.sh b/scripts/stop.sh new file mode 100755 index 0000000..34a3a51 --- /dev/null +++ b/scripts/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +DIR="$(cd "$(dirname "$0")" && pwd)" + +cd $DIR/.. +docker-compose down -- cgit v1.2.3