Skip to content

zauberware/capistrano-nextjs

Repository files navigation

Capistrano::Nextjs

Next.js integration for Capistrano with systemd support.

Installation

Add this line to your application's Gemfile:

gem 'capistrano-nextjs'

And then execute:

bundle install

Usage

Add the following to your Capfile:

require 'capistrano/pnpm'
require 'capistrano/nextjs'
install_plugin Capistrano::NextjsPlugin
install_plugin Capistrano::NextjsSystemd

Add the following to your config/deploy.rb:

# Next.js configuration
set :nextjs_roles, :app
set :nextjs_env, fetch(:stage)

Available Tasks

Deployment

  • cap nextjs:start - Start Next.js application
  • cap nextjs:stop - Stop Next.js application
  • cap nextjs:restart - Restart Next.js application
  • cap nextjs:status - Check Next.js application status
  • cap nextjs:install - Install systemd service
  • cap nextjs:uninstall - Uninstall systemd service
  • cap nextjs:build - Build Next.js application
  • cap nextjs:check - Check Next.js application (lint)

Logs

  • 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

Configuration

set :logs_tail_lines, 100  # number of lines to show on connect (default: 100)
set :rake_roles, :app      # roles to stream logs from

Configuration

The gem automatically integrates with your deployment process:

  • Stops the service before deployment
  • Starts the service after successful deployment
  • Restarts the service if deployment fails

Requirements

  • Node.js
  • pnpm
  • systemd (for service management)

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors