Browse Source

fix: Create fixer for software_update

- Restart power_request service when software updated.
pull/12/head
Bugra Isguzar 1 year ago
parent
commit
1a86ea563c
3 changed files with 7 additions and 3 deletions
  1. 1
    1
      agent.py
  2. 2
    2
      core/modules/updater.py
  3. 4
    0
      fixer.py

+ 1
- 1
agent.py View File

@@ -4,7 +4,7 @@ import os
from core import Agent
from configparser import ConfigParser

__version__ = "0.3.5"
__version__ = "0.3.6"

environments_object = ConfigParser()
environments_object.read("/opt/sixfab/.env")

+ 2
- 2
core/modules/updater.py View File

@@ -114,8 +114,7 @@ def update_agent(**kwargs):
&& sudo git reset --hard HEAD
{'&& sudo git fetch && sudo git checkout dev' if experimental_enabled else ''}
&& sudo git pull
&& sudo pip3 install -r requirements.txt
&& pip3 install .
&& sudo pip3 install -r requirements.txt
""".replace("\n", ""))
os.system("pip3 install -U sixfab-power-python-api")
@@ -123,5 +122,6 @@ def update_agent(**kwargs):
send_status("restart")

os.system("sudo systemctl restart power_agent")
os.system("sudo systemctl restart power_request")

send_status("finish")

+ 4
- 0
fixer.py View File

@@ -26,3 +26,7 @@ ExecStart=/usr/bin/python3 /opt/sixfab/pms/api/run_server.py
WantedBy=multi-user.target"|sudo tee /etc/systemd/system/sixfab_power_api.service;sudo systemctl daemon-reload;sudo systemctl enable sixfab_power_api;sudo systemctl start sixfab_power_api;fi""")

execute_fix("23.10.2020-update-service-names", r'if [ -f "/etc/systemd/system/sixfab_power_api.service" ];then sudo systemctl disable sixfab_power_api;sudo systemctl stop sixfab_power_api;sudo mv /etc/systemd/system/sixfab_power_api.service /etc/systemd/system/power_request.service;sudo systemctl daemon-reload;sudo systemctl enable power_request;sudo systemctl start power_request;fi;if [ -f "/etc/systemd/system/pms_agent.service" ];then sudo systemctl disable pms_agent;sudo mv /etc/systemd/system/pms_agent.service /etc/systemd/system/power_agent.service;sudo systemctl daemon-reload;sudo systemctl enable power_agent;sudo systemctl start power_agent;sudo systemctl stop pms_agent;fi')

execute_fix("23.10.2020-update-service-names", r'if [ -f "/etc/systemd/system/sixfab_power_api.service" ];then sudo systemctl disable sixfab_power_api;sudo systemctl stop sixfab_power_api;sudo mv /etc/systemd/system/sixfab_power_api.service /etc/systemd/system/power_request.service;sudo systemctl daemon-reload;sudo systemctl enable power_request;sudo systemctl start power_request;fi;if [ -f "/etc/systemd/system/pms_agent.service" ];then sudo systemctl disable pms_agent;sudo mv /etc/systemd/system/pms_agent.service /etc/systemd/system/power_agent.service;sudo systemctl daemon-reload;sudo systemctl enable power_agent;sudo systemctl start power_agent;sudo systemctl stop pms_agent;fi')

execute_fix("19.12.2020-restart-request-service", r'sudo systemctl restart power_request')

Loading…
Cancel
Save