Skip to content

Commit

Permalink
feat: pprof for run command
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyxdd committed Aug 5, 2023
1 parent 531b23b commit 2c7db03
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hyperbole.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def cmd_build(pprof=False, release=False):
print("Built %s" % out_name)


def cmd_run(args):
def cmd_run(args, pprof=False):
if not check_build_env():
return

Expand All @@ -182,6 +182,9 @@ def cmd_run(args):
]

cmd = ["go", "run", "-ldflags", " ".join(ldflags)]
if pprof:
cmd.append("-tags")
cmd.append("pprof")
cmd.append(APP_SRC_DIR)
cmd.extend(args)

Expand Down Expand Up @@ -237,6 +240,8 @@ def main():

# Run
p_run = p_cmd.add_parser("run", help="Run the app")
p_run.add_argument("-p", "--pprof", action="store_true",
help="Run with pprof enabled")
p_run.add_argument("args", nargs=argparse.REMAINDER)

# Build
Expand All @@ -261,7 +266,7 @@ def main():
args = parser.parse_args()

if args.command == "run":
cmd_run(args.args)
cmd_run(args.args, args.pprof)
elif args.command == "build":
cmd_build(args.pprof, args.release)
elif args.command == "format":
Expand Down

0 comments on commit 2c7db03

Please sign in to comment.