Easy application dependency management with Stratopan
Good Perl authors write modular code and leverage CPAN as much as possible. The downside of this approach is that Perl applications accumulate hundreds of CPAN module dependencies. Fortunately for Perl, Stratopan makes it simple to manage your application dependencies and quickly deploy it to new environments.
How many dependencies?!
Perl application dependencies grow rapidly. This is because every time you import a module, you take on that module’s dependencies, and those of its imports and so on. The cover picture above shows the dependencies graph for the PerlTricks.com application; it’s 283 modules. That’s a lot of code to manage.
Manage module dependencies with Stratopan
Stratopan, the cloud-based module hosting service, let’s you upload Perl modules to a personal repository in the cloud. On our PerlTricks stack, we’ve uploaded the exact versions of all of the modules used in our production environment. Many of the modules are not up to date, but that doesn’t matter as these are the module versions that work.
Rapid Deployment
Deploying this stack to a fresh environment couldn’t be easier. We can use cpanm to read our Makefile.PL and recursively install our application dependencies, using Stratopan as the source. In the terminal we navigate to the root application directory and enter:
$ cpanm -n --installdeps --mirror-only --mirror https://stratopan.com/sillymoose/WebStuff/perltricks .
Let’s review this code: first we use cpanm’s “-n” switch to turn off module tests to install the modules super-fast. The “–installdeps” switch makes cpanm look for application dependencies. The “mirror” switches instruct cpan to use our Stratopan stack as the install source. The trailing period indicates to search for dependencies in the current directory. This is the perfect marriage: Stratopan recursively pulled our module dependencies into our stack, and cpanm recursively installs all dependencies it finds. Even though our Makefile lists ~40 modules, cpanm ends up installing all 283.
When we want to upgrade our modules we can do it in a controlled way by making a copy of our stack upgrading the modules for testing in a development environment, before upgrading production.
Conclusion
Without Stratopan and cpanm, deploying the PerlTricks application to a new server would be a lot more work. We’d either have to list and source the specific module versions and deploy them manually, or else install the newest versions of all of 283 dependencies and hope they still play nice with each other. Two of our dependences are no longer even on CPAN!
Want to get started with Stratopan? Check out our quick start user guide.
Enjoyed this article? Help us out and retweet it!
This article was originally posted on PerlTricks.com.
Tags
David Farrell
David is a professional programmer who regularly tweets and blogs about code and the art of programming.
Browse their articles
Feedback
Something wrong with this article? Help us out by opening an issue or pull request on GitHub