Skip to content

Commit

Permalink
Merge pull request #183 from valory-xyz/fix/start-button-grayed-out
Browse files Browse the repository at this point in the history
pause all service on startup
  • Loading branch information
truemiller authored Jun 18, 2024
2 parents 49b034e + d46d371 commit f7fc8c6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { BrewScript } = require('./scripts');
* - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26"
* - use "alpha" for alpha release, for example "0.1.0rc26-alpha"
*/
const OlasMiddlewareVersion = '0.1.0rc47';
const OlasMiddlewareVersion = '0.1.0rc50';
const OperateDirectory = `${os.homedir()}/.operate`;
const VenvDir = `${OperateDirectory}/venv`;
const TempDir = `${OperateDirectory}/temp`;
Expand Down
21 changes: 20 additions & 1 deletion operate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from operate.account.user import UserAccount
from operate.constants import KEY, KEYS, OPERATE, SERVICES
from operate.ledger import get_ledger_type_from_chain_type
from operate.types import ChainType
from operate.types import ChainType, DeploymentStatus
from operate.wallet.master import MasterWalletManager


Expand Down Expand Up @@ -179,6 +179,25 @@ def cancel_funding_job(service: str) -> None:
if not status:
logger.info(f"Funding job cancellation for {service} failed")

def pause_all_services_on_startup():
logger.info(f"stopping services on startup")
services = [i["hash"] for i in operate.service_manager().json]

for service in services:
if not operate.service_manager().exists(service=service):
continue
deployment = operate.service_manager().create_or_load(service).deployment
if deployment.status == DeploymentStatus.DELETED:
continue
logger.info(f"stopping service {service}")
deployment.stop(force=True)
logger.info(f"Cancelling funding job for {service}")
cancel_funding_job(service=service)
logger.info(f"stopping services on startup: done")

# on backend app started we assume there are now started agents, so we force to pause all
pause_all_services_on_startup()

app = FastAPI()

app.add_middleware(
Expand Down
4 changes: 2 additions & 2 deletions operate/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,9 @@ def start(self, use_docker: bool = False) -> None:
self.status = DeploymentStatus.DEPLOYED
self.store()

def stop(self, use_docker: bool = False) -> None:
def stop(self, use_docker: bool = False, force: bool=False) -> None:
"""Stop the deployment."""
if self.status != DeploymentStatus.DEPLOYED:
if self.status != DeploymentStatus.DEPLOYED and not force:
return

self.status = DeploymentStatus.STOPPING
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"main": "electron/main.js",
"name": "olas-operate-app",
"productName": "Pearl",
"version": "0.1.0-rc47",
"version": "0.1.0-rc50",
"dependencies": {
"@ant-design/cssinjs": "^1.18.4",
"@ant-design/icons": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "olas-operate-middleware"
version = "0.1.0-rc47"
version = "0.1.0-rc50"
description = ""
authors = ["David Vilela <[email protected]>", "Viraj Patel <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit f7fc8c6

Please sign in to comment.