caddyphpfpm

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 16 Imported by: 0

README

Caddy PHP-FPM 
=============

A module to run and supervise php-fpm in the background

This module is optimised for running a PHP app using caddy in Google Cloud Run
in that it will not let Caddy start until php-fpm has started. Otherwise Google
Cloud run will see your port is open and start serving to it.

How it works
------------

This will spawn a php-fpm process in the background and prevent caddy from starting till it's
up and running. When Caddy stops, the php-fpm process will also be stopped.

Full HTTP Caddyfile example
--------------------------

Caddyfile::

    {
        # Must be in global options
        php-fpm {
            cmd php-fpm -y fpm.conf
            sock_location path/to/fpm.sock
            start_timeout 10s
        }
    }

    mysite.com {
        @trailing-slash {
            path_regexp dir (.+)/$
        }
        rewrite @trailing-slash {re.dir.1}

        root * /var/www

        try_files {path} {path}.php {path}/index.php =404
        php_fastcgi unix/path/to/fpm.sock
    }

Building it
-----------

Use the `xcaddy` tool to build a version of caddy with this module::

    xcaddy build \
        --with github.com/delfick/caddy_php_fpm

Credits
-------

This package is a stripped down version of https://github.com/baldinof/caddy-supervisor,
which itself is a continuation of https://github.com/lucaslorentz/caddy-supervisor
which only supports Caddy v1.

Thanks @lucaslorentz and @baldinof for the original works!

Documentation

Index

Constants

This section is empty.

Variables

L is the global logger to be used by the app So when we need to log we import it and use log.L.<method>(...)

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp() *App

NewApp returns a new App object

func (*App) CaddyModule

func (a *App) CaddyModule() caddy.ModuleInfo

CaddyModule implements caddy.Module

func (*App) Cleanup added in v0.3.0

func (a *App) Cleanup() error

func (*App) Provision

func (a *App) Provision(ctx caddy.Context) error

func (*App) Start

func (a *App) Start() error

Start implements caddy.App

func (*App) Stop

func (a *App) Stop() error

Stop implements caddy.App

type PHP

type PHP struct {
	// contains filtered or unexported fields
}

PHP provides functionality to start and supervise php-fpm in the background

func NewPHP added in v0.2.0

func NewPHP() *PHP

func (*PHP) Run

func (p *PHP) Run()

Run a process and supervise

func (*PHP) Stop

func (p *PHP) Stop()

Stop the supervised process

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL