Created
August 31, 2019 07:40
-
-
Save antoniogamiz/8837c32c57cfa6eb06a90da59dc56fe4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Cro::HTTP::Server; | |
use Cro::HTTP::Router; | |
my $PORT = 2314; | |
say "Starting server..."; | |
say "Listening on port $PORT..."; | |
my $application = route { | |
post -> { | |
say "POST at {~DateTime.now.utc.truncated-to('seconds')}"; | |
shell 'git pull'; # update pod files | |
shell 'documentable update'; # update html collection | |
} | |
} | |
# Create the HTTP service object | |
my Cro::Service $service = Cro::HTTP::Server.new( | |
:host('localhost'), :port($PORT), :$application | |
); | |
# Run it | |
$service.start; | |
# Cleanly shut down on Ctrl-C | |
react whenever signal(SIGINT) { | |
$service.stop; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment