Next.js integration for Capistrano with systemd support.
Add this line to your application's Gemfile:
gem 'capistrano-nextjs'And then execute:
bundle installAdd the following to your Capfile:
require 'capistrano/pnpm'
require 'capistrano/nextjs'
install_plugin Capistrano::NextjsPlugin
install_plugin Capistrano::NextjsSystemdAdd the following to your config/deploy.rb:
# Next.js configuration
set :nextjs_roles, :app
set :nextjs_env, fetch(:stage)cap nextjs:start- Start Next.js applicationcap nextjs:stop- Stop Next.js applicationcap nextjs:restart- Restart Next.js applicationcap nextjs:status- Check Next.js application statuscap nextjs:install- Install systemd servicecap nextjs:uninstall- Uninstall systemd servicecap nextjs:build- Build Next.js applicationcap nextjs:check- Check Next.js application (lint)
cap logs:info- Stream the Next.js application log (green output)cap logs:error- Stream the Next.js error log (red output)cap logs:all- Stream both logs simultaneously, color-coded by source
Press Ctrl+C to stop streaming.
The log tasks use a custom SSHKit formatter to colorize output directly in your terminal:
| Task | File | Color |
|---|---|---|
logs:info |
shared/log/nextjs.log |
Green |
logs:error |
shared/log/nextjs-error.log |
Red |
logs:all |
both | Green / Red |
set :logs_tail_lines, 100 # number of lines to show on connect (default: 100)
set :rake_roles, :app # roles to stream logs fromThe gem automatically integrates with your deployment process:
- Stops the service before deployment
- Starts the service after successful deployment
- Restarts the service if deployment fails
- Node.js
- pnpm
- systemd (for service management)
The gem is available as open source under the terms of the MIT License.