Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created May 14, 2020 16:43
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 AlexDaniel/0eb7e8cce5639889a6d11fa5d376f941 to your computer and use it in GitHub Desktop.
Save AlexDaniel/0eb7e8cce5639889a6d11fa5d376f941 to your computer and use it in GitHub Desktop.

bar

This is an application stub generated by cro stub. To try it out, you'll need to have Cro installed; you can do so using:

zef install --/test cro

Then change directory to the app root (the directory containing this README.md file), and run these commands:

zef install --depsonly .
cro run

You can also build and run a docker image while in the app root using:

docker build -t bar .
docker run --rm -p 10000:10000 bar
FROM croservices/cro-http:0.8.2
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN zef install --deps-only . && perl6 -c -Ilib service.p6
ENV BAR_HOST="0.0.0.0" BAR_PORT="10000"
EXPOSE 10000
CMD perl6 -Ilib service.p6
use Cro::HTTP::Router;
sub routes() is export {
route {
get -> {
content 'text/html', "<h1> bar </h1>";
}
}
}
{
"authors": [
""
],
"version": "0.0.1",
"depends": [
"Cro::HTTP"
],
"perl": "6.*",
"description": "Write me!",
"resources": [
],
"license": "Write me!",
"tags": [
""
],
"support": {
"source": "Write me!"
},
"meta-version": "0",
"source-url": "Write me!",
"name": "bar",
"build-depends": [
],
"provides": {
"Routes.pm6": "lib/Routes.pm6"
},
"test-depends": [
],
"auth": "Write me!"
}
use Cro::HTTP::Log::File;
use Cro::HTTP::Server;
use Routes;
my Cro::Service $http = Cro::HTTP::Server.new(
http => <1.1>,
host => %*ENV<BAR_HOST> ||
die("Missing BAR_HOST in environment"),
port => %*ENV<BAR_PORT> ||
die("Missing BAR_PORT in environment"),
application => routes(),
after => [
Cro::HTTP::Log::File.new(logs => $*OUT, errors => $*ERR)
]
);
$http.start;
say "Listening at http://%*ENV<BAR_HOST>:%*ENV<BAR_PORT>";
react {
whenever signal(SIGINT) {
say "Shutting down...";
$http.stop;
done;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment