From 21b9d93ce9a79196ac36799509f3f808f347df8f Mon Sep 17 00:00:00 2001 From: tomjohnburton <39559415+tomjohnburton@users.noreply.github.com> Date: Wed, 18 Oct 2023 12:56:09 +0200 Subject: [PATCH] feat: required changes for multi engine release (#4123) Co-authored-by: dandanlen <3168260+dandanlen@users.noreply.github.com> Co-authored-by: Daniel --- .github/workflows/_10_test.yml | 22 ----- engine/Cargo.toml | 12 ++- ...e.service => chainflip-engine0.10.service} | 2 +- engine/package/perseverance/preinst | 88 ------------------- ...e.service => chainflip-engine0.10.service} | 2 +- 5 files changed, 11 insertions(+), 115 deletions(-) rename engine/package/perseverance/{chainflip-engine.service => chainflip-engine0.10.service} (81%) delete mode 100755 engine/package/perseverance/preinst rename engine/package/sisyphos/{chainflip-engine.service => chainflip-engine0.10.service} (74%) diff --git a/.github/workflows/_10_test.yml b/.github/workflows/_10_test.yml index 0f9c9721ad..d00336c3f1 100644 --- a/.github/workflows/_10_test.yml +++ b/.github/workflows/_10_test.yml @@ -59,25 +59,3 @@ jobs: token: ${{ secrets.CF_BACKEND_CODECOV_TOKEN }} # not required for public repos files: lcov.info fail_ci_if_error: false - - test-preinst-scripts: - runs-on: ubuntu-latest - strategy: - matrix: - tests_path: - - state-chain/node/package/preinst-tests - - engine/package/preinst-tests - steps: - - name: Checkout ๐Ÿ - uses: actions/checkout@v3 - - - name: Install bats ๐Ÿฆ‡ - run: | - sudo apt-get update - sudo apt-get install -y bats - - - name: Test ๐Ÿงช - shell: bash - run: | - bats tests/test_preinst.bats - working-directory: ${{ matrix.tests_path }} diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 9fec20bf2b..118cf94d4a 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -11,11 +11,17 @@ extended-description = """\ Chainflip Validator Engine Package""" maintainer = "Chainflip Labs GmbH " maintainer-scripts = "package/" -name = "chainflip-engine" +name = "chainflip-engine0.10" priority = "required" section = "rust" -systemd-units = { unit-name = "chainflip-engine", enable = false } -assets = [["target/release/chainflip-engine", "usr/bin/", "755"]] +systemd-units = [{ unit-name = "chainflip-engine0.10", enable = false }] +assets = [ + [ + "target/release/chainflip-engine", + "usr/bin/chainflip-engine0.10", + "755", + ], +] [package.metadata.deb.variants.development] maintainer-scripts = "package/development" diff --git a/engine/package/perseverance/chainflip-engine.service b/engine/package/perseverance/chainflip-engine0.10.service similarity index 81% rename from engine/package/perseverance/chainflip-engine.service rename to engine/package/perseverance/chainflip-engine0.10.service index c1c2318de5..5e7da7d243 100644 --- a/engine/package/perseverance/chainflip-engine.service +++ b/engine/package/perseverance/chainflip-engine0.10.service @@ -7,7 +7,7 @@ Restart=always RestartSec=30 Type=simple -ExecStart=/usr/bin/chainflip-engine --config-root /etc/chainflip/ +ExecStart=/usr/bin/chainflip-engine0.10 --config-root /etc/chainflip/ Environment=RUST_LOG="chainflip_engine=debug,multisig=debug,warn,chainflip_engine::p2p=error" LimitNOFILE=16000 LimitNOFILESoft=16000 diff --git a/engine/package/perseverance/preinst b/engine/package/perseverance/preinst deleted file mode 100755 index fff2c8898d..0000000000 --- a/engine/package/perseverance/preinst +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -set -e - -CF_ROOT=/etc/chainflip -CF_ENGINE_TARGET_VERSION="0.9" -SYSTEMD_PATH=/etc/systemd/system -CF_ENGINE_CONFIG_FILE="$CF_ROOT/config/Settings.toml" - -check_upgrade() { - if [ "$1" != "upgrade" ]; then - echo "chainflip-engine: Fresh install detected, skipping migration" - exit 0 - else - echo "chainflip-engine: Upgrade detected, migrating" - fi -} - -stop_service() { - if systemctl is-active --quiet chainflip-engine; then - if systemctl stop chainflip-engine; then - echo "chainflip-engine stopped" - else - echo "Error stopping chainflip-engine" - exit 1 - fi - else - echo "chainflip-engine is already stopped" - fi -} - -check_version() { - CF_NODE_CURRENT_VERSION=$(chainflip-engine -V) - if echo "$CF_NODE_CURRENT_VERSION" | grep $CF_ENGINE_TARGET_VERSION > /dev/null; then - echo "chainflip-engine: skipping migration" - exit 0 - else - echo "chainflip-engine: Detected older version, migrating" - fi -} - -backup_and_remove_systemd_overrides() { - if [ -f $SYSTEMD_PATH/chainflip-engine.service.d/override.conf ]; then - echo "chainflip-engine: systemd overrides found - backing up and removing" - mv $SYSTEMD_PATH/chainflip-engine.service.d/override.conf $SYSTEMD_PATH/chainflip-engine.service.d.bak/override.conf - fi -} - -remove_old_keyshares() { - if [ -d "$CF_ROOT/data.db" ]; then - echo "chainflip-engine: Removing old data.db directory" - rm -rf "$CF_ROOT/data.db" - fi -} - -remove_old_logs() { - if [ -f "/var/log/chainflip-engine.log" ]; then - echo "chainflip-engine: Removing old log file" - rm -rf "/var/log/chainflip-engine*" - fi -} - -update_engine_config() { - echo "chainflip-engine: Updating engine config" -} - -reload_systemctl() { - systemctl daemon-reload -} - -# Main entry point -main() { - check_upgrade "$1" - check_version - stop_service - remove_old_keyshares - backup_and_remove_systemd_overrides - remove_old_logs - update_engine_config - reload_systemctl -} - -# Only run the main function if the script is not being sourced -# This allows you to source the script in your tests without running main -if [ "${BASH_SOURCE[0]}" = "${0}" ]; then - main "$@" -fi - -# #DEBHELPER# diff --git a/engine/package/sisyphos/chainflip-engine.service b/engine/package/sisyphos/chainflip-engine0.10.service similarity index 74% rename from engine/package/sisyphos/chainflip-engine.service rename to engine/package/sisyphos/chainflip-engine0.10.service index 7b6698c16e..789d1f9dda 100644 --- a/engine/package/sisyphos/chainflip-engine.service +++ b/engine/package/sisyphos/chainflip-engine0.10.service @@ -7,7 +7,7 @@ Restart=always RestartSec=30 Type=simple -ExecStart=/usr/bin/chainflip-engine --config-root /etc/chainflip/ +ExecStart=/usr/bin/chainflip-engine0.10 --config-root /etc/chainflip/ LimitNOFILE=16000 LimitNOFILESoft=16000