Closed vdye closed 1 year ago
@derrickstolee @ldennington just pushed changes to de-duplicate some subcommand-related code, summary of changes is:
Command
back to Subcommand
, move to argparse
package, make all functions public.argParser.Subcommand()
take a Subcommand
instance as an argument, rather than individual name/description/run function args.genericSubcommand
to handle subcommands specified with static name/description/run function (e.g. web-server start
and web-server stop
).
Overview
This pull request is made up of two main changes (the second depends on the first):
bundle-server: update commands to use arg parser
)git-bundle-server web-server
uses both flags & subcommands, it seemed like a good opportunity to improve argument parsing across the repository 😁Subcommand
interface & adding thedescription()
with information pulled mostly fromREADME.md
)main.go
and each subcommand to use the arg parsergit-bundle-server web-server (start|stop)
command for MacOS and Linuxlaunchd
orsystemd
(depending on the OS) to start or stop thegit-bundle-web-server
.launchd
Create()
,Start()
, andStop()
functions and unit tests those functions (using the mocked interfaces from the prior commits).systemd
functions, including unit testing.git-bundle-web-server
to interceptSIGTERM
andSIGINT
signals to trigger a graceful shutdown & cleanup of resources.SIGKILL
will still ungracefully shut down, however.git-bundle-server web-server (start|stop)
command. It generates the configuration needed by the daemon provider (finds the path togit-bundle-web-server
by first searching on thePATH
, then in the same directory as the runninggit-bundle-server
executable), then creates and invokes the appropriate daemon provider.Testing
I did some basic manual testing on both MacOS (local machine) and Linux (Ubuntu VM), and the services started & stopped successfully. Proper integration tests are needed to verify edge-case behavior and ensure we don't regress over time (it's on the project's TODO list 😉).
Leftover bits
launchd
/launchctl
)web-server (start|stop)