Skip to content

Instantly share code, notes, and snippets.

@antoniogamiz
Created August 31, 2019 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniogamiz/8837c32c57cfa6eb06a90da59dc56fe4 to your computer and use it in GitHub Desktop.
Save antoniogamiz/8837c32c57cfa6eb06a90da59dc56fe4 to your computer and use it in GitHub Desktop.
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