mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-25 09:00:26 +00:00
up error
This commit is contained in:
parent
cbeaad59bc
commit
b1063250c7
5 changed files with 74 additions and 15 deletions
BIN
cli/__pycache__/controller.cpython-36.pyc
Normal file
BIN
cli/__pycache__/controller.cpython-36.pyc
Normal file
Binary file not shown.
BIN
cli/__pycache__/model.cpython-36.pyc
Normal file
BIN
cli/__pycache__/model.cpython-36.pyc
Normal file
Binary file not shown.
|
@ -104,6 +104,40 @@ class Create:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Manage(model.DockerComposeOp):
|
class Status:
|
||||||
|
|
||||||
|
'''The status operation of project, e.g Start | Stop | Restart | Erase'''
|
||||||
|
|
||||||
|
def __init__(self, project_name: str, project_path: Optional[str] = None):
|
||||||
|
|
||||||
|
self.project_name = project_name
|
||||||
|
self.project_path = project_path
|
||||||
|
self.dockerop = model.DockerOp()
|
||||||
|
|
||||||
|
projectdict = self.dockerop.getProject()
|
||||||
|
|
||||||
|
if self.project_path == None:
|
||||||
|
try:
|
||||||
|
self.project_path = projectdict[self.project_name]
|
||||||
|
self.dockercomposeop = model.DockerComposeOp(self.project_path)
|
||||||
|
except:
|
||||||
|
print("No this application!")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
def stopApp(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def upApp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def startApp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def retartApp(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def eraseApp(self):
|
||||||
|
self.dockercomposeop.down()
|
||||||
|
|
||||||
|
def upApp(self):
|
||||||
|
self.dockercomposeop.up(self.project_path)
|
12
cli/model.py
12
cli/model.py
|
@ -115,7 +115,7 @@ class SecurityOp:
|
||||||
class DockerComposeOp:
|
class DockerComposeOp:
|
||||||
'''Docker Compose operation'''
|
'''Docker Compose operation'''
|
||||||
|
|
||||||
def __int__(self, path: Optional[str] = ""):
|
def __init__(self, path: Optional[str] = ''):
|
||||||
|
|
||||||
self.cmd_up = "docker-compose up -d"
|
self.cmd_up = "docker-compose up -d"
|
||||||
self.cmd_stop = "docker-compose stop"
|
self.cmd_stop = "docker-compose stop"
|
||||||
|
@ -125,22 +125,22 @@ class DockerComposeOp:
|
||||||
try:
|
try:
|
||||||
os.chdir(self.path)
|
os.chdir(self.path)
|
||||||
except:
|
except:
|
||||||
print("No found project directory")
|
print("Not found project directory")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def up(self):
|
def up(self):
|
||||||
'''docker-compose up'''
|
'''docker-compose up'''
|
||||||
try:
|
try:
|
||||||
os.system(cmd_up)
|
os.system(self.cmd_up)
|
||||||
except:
|
except:
|
||||||
print("Create failed")
|
print("Create failed")
|
||||||
os.system(cmd_up)
|
os.system(self.cmd_up)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
'''docker-compose stop'''
|
'''docker-compose stop'''
|
||||||
try:
|
try:
|
||||||
os.system(cmd_stop)
|
os.system(self.cmd_stop)
|
||||||
except:
|
except:
|
||||||
print("Stop failed, suggest try it again")
|
print("Stop failed, suggest try it again")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -148,7 +148,7 @@ class DockerComposeOp:
|
||||||
def down(self):
|
def down(self):
|
||||||
'''docker-compose down'''
|
'''docker-compose down'''
|
||||||
try:
|
try:
|
||||||
os.system(cmd_down)
|
os.system(self.cmd_down)
|
||||||
except:
|
except:
|
||||||
print("Down failed, suggest try it again")
|
print("Down failed, suggest try it again")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -24,14 +24,39 @@ def create(app_name: str, project_name: Optional[str] = None):
|
||||||
create.printResult()
|
create.printResult()
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def start(app_name: str, project_name: Optional[str] = None):
|
def up(path: str):
|
||||||
'''start one application'''
|
'''up one deleted application'''
|
||||||
pass
|
status = controller.Status("application", path)
|
||||||
|
status.startApp()
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def update(name: str):
|
def start(project_name: str):
|
||||||
|
'''start one stopped application'''
|
||||||
|
status = controller.Status(project_name)
|
||||||
|
status.startApp()
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def stop(project_name: str):
|
||||||
|
'''start one running application'''
|
||||||
|
status = controller.Status(project_name)
|
||||||
|
status.stopApp()
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def restart(project_name: str):
|
||||||
|
'''Restart one application'''
|
||||||
|
status = controller.Status(project_name)
|
||||||
|
status.retartApp()
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def erase(project_name: str):
|
||||||
|
'''erase or delete an application'''
|
||||||
|
status = controller.Status(project_name)
|
||||||
|
status.eraseApp()
|
||||||
|
|
||||||
|
@app.command()
|
||||||
|
def update(project_name: str):
|
||||||
'''update the local lists cache'''
|
'''update the local lists cache'''
|
||||||
typer.echo(f"Hello {name}")
|
typer.echo(f"Hello {project_name}")
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
|
|
Loading…
Reference in a new issue