Get started with the Perl hosting integration
Ce contenu n’est pas encore disponible dans votre langue.
The Aspire Community Toolkit Perl hosting integration runs Perl applications alongside the other resources in your AppHost. It models a Perl process as a first-class resource, manages its working directory and dependency installers, and supports local development and Dockerfile-based publishing.
How the integration fits together
Section titled “How the integration fits together”The hosting package belongs in the AppHost. It creates an executable resource for your Perl application, while your project retains its scripts, modules, and dependency files.
architecture-beta group apphost(server)[AppHost] group perl(logos:perl)[Perl project] service hosting(server)[Perl hosting integration] in apphost service resource(logos:perl)[Perl app resource] in apphost service runtime(logos:perl)[Perl runtime] in perl service app(logos:perl)[Perl application] in perl hosting:R --> L:resource resource:R --> L:runtime runtime:R --> L:app
Prerequisites
Section titled “Prerequisites”- Install Perl and ensure
perlandcpanare onPATH. - Install
cpanmwhen you useWithCpanMinus,WithLocalLib, or project dependency installation without Carton. Installcartonwhen you use Carton. - Install the Aspire CLI and create an AppHost.
Add the hosting package
Section titled “Add the hosting package”Add CommunityToolkit.Aspire.Hosting.Perl to your AppHost. The Perl hosting reference includes package installation options.
Add a Perl resource
Section titled “Add a Perl resource”Add a script resource and use a project-local module directory:
var builder = DistributedApplication.CreateBuilder(args);
builder.AddPerlScript("worker", "../perl-worker", "worker.pl") .WithLocalLib("local");
builder.Build().Run();import { createBuilder } from './.aspire/modules/aspire.mjs';
const builder = await createBuilder();
const worker = await builder.addPerlScript( 'worker', '../perl-worker', 'worker.pl');await worker.withLocalLib('local');
await builder.build().run();Configure dependencies and endpoints
Section titled “Configure dependencies and endpoints”The resource’s application directory is its working directory. Put a cpanfile there when you want Aspire to install project dependencies, and add an HTTP endpoint for a web API that listens on a port.
Set up Perl in the AppHost