feat(server): add rebuild option for server
This commit is contained in:
13
aklive2d.py
13
aklive2d.py
@@ -49,6 +49,13 @@ class AkLive2D:
|
|||||||
required=True,
|
required=True,
|
||||||
help="<Required> Operatro to develop",
|
help="<Required> Operatro to develop",
|
||||||
)
|
)
|
||||||
|
server.add_argument(
|
||||||
|
"-r",
|
||||||
|
"--rebuild",
|
||||||
|
dest="rebuild",
|
||||||
|
action='store_true',
|
||||||
|
help="Rebuild assets"
|
||||||
|
)
|
||||||
|
|
||||||
build = subprasers.add_parser(
|
build = subprasers.add_parser(
|
||||||
"build",
|
"build",
|
||||||
@@ -65,7 +72,6 @@ class AkLive2D:
|
|||||||
nargs='+',
|
nargs='+',
|
||||||
help="Operators to build"
|
help="Operators to build"
|
||||||
)
|
)
|
||||||
|
|
||||||
build.add_argument(
|
build.add_argument(
|
||||||
"-r",
|
"-r",
|
||||||
"--rebuild",
|
"--rebuild",
|
||||||
@@ -76,9 +82,8 @@ class AkLive2D:
|
|||||||
|
|
||||||
self.args = parser.parse_args()
|
self.args = parser.parse_args()
|
||||||
if self.args.command == "server" or self.args.command == "s":
|
if self.args.command == "server" or self.args.command == "s":
|
||||||
self.running = Server(self.args.port, self.args.operator_name, self.config)
|
self.running = Server(self.args.port, self.args.operator_name, self.config, self.args.rebuild)
|
||||||
|
elif self.args.command == "build" or self.args.command == "b":
|
||||||
if self.args.command == "build" or self.args.command == "b":
|
|
||||||
self.running = Builder(self.config, self.args.operator_names, self.args.rebuild)
|
self.running = Builder(self.config, self.args.operator_names, self.args.rebuild)
|
||||||
|
|
||||||
self.running.start()
|
self.running.start()
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ from lib.builder import Builder
|
|||||||
from lib.html_processor import HtmlProcessor
|
from lib.html_processor import HtmlProcessor
|
||||||
class Server:
|
class Server:
|
||||||
|
|
||||||
def __init__(self, port, operator, config) -> None:
|
def __init__(self, port, operator, config, rebuild) -> None:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.operator = operator
|
self.operator = operator
|
||||||
self.port = port
|
self.port = port
|
||||||
|
self.rebuild = rebuild
|
||||||
self.httpd = TCPServer(("", port), httpd(operator, config, directory=str(pathlib.Path.cwd())))
|
self.httpd = TCPServer(("", port), httpd(operator, config, directory=str(pathlib.Path.cwd())))
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
# build assets first
|
# build assets first
|
||||||
Builder(self.config).build_assets(self.operator)
|
Builder(self.config, rebuild=self.rebuild).build_assets(self.operator)
|
||||||
print("Server is up at 0.0.0.0:{port}".format(port=self.port))
|
print("Server is up at 0.0.0.0:{port}".format(port=self.port))
|
||||||
self.httpd.serve_forever()
|
self.httpd.serve_forever()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user