Documentation ¶
Index ¶
- func FindBinary(dirPaths ...string) (fpmPath string, err error)
- func ReadPaths(envPath string) (dirPaths []string)
- type Process
- func (proc *Process) Address() (network, address string)
- func (proc *Process) Config() (f *ini.File)
- func (proc *Process) SaveConfig(path string)
- func (proc *Process) SetDatadir(prefix string)
- func (proc *Process) SetName(name string)
- func (proc *Process) Start() (err error)
- func (proc *Process) Stop() error
- func (proc *Process) Wait() (err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindBinary ¶
FindBinary finds php-fpm binary in the given paths.
Will return ErrNotExist or other syscall error if it have problem finding the file. Will return other errors when reading from bad input / directory system.
Types ¶
type Process ¶
type Process struct { // basename for pid / sock / log filename Name string // path to php-fpm executable Exec string // path to the config file ConfigFile string // username of the FastCGI process User string // The address on which to accept FastCGI requests. // Valid syntaxes are: 'ip.add.re.ss:port', 'port', // '/path/to/unix/socket'. This option is mandatory for each pool. Listen string // path of the PID file PidFile string // path of the error log ErrorLog string // contains filtered or unexported fields }
Process describes a minimalistic php-fpm config that runs only 1 pool
Example ¶
package main import ( "time" "github.com/yookoala/gofast/tools/phpfpm" ) var username, basepath, pathToPhpFpm string func main() { process := phpfpm.NewProcess(pathToPhpFpm) // SetDatadir equals to running these 3 settings: // process.PidFile = basepath + "/phpfpm.pid" // process.ErrorLog = basepath + "/phpfpm.error_log" // process.Listen = basepath + "/phpfpm.sock" process.SetDatadir(basepath + "/var") process.User = username // save the config file to basepath + "/etc/php-fpm.conf" process.SaveConfig(basepath + "/etc/example.conf") process.Start() go func() { // do something that needs phpfpm // ... time.Sleep(time.Millisecond * 50) process.Stop() }() process.Wait() }
Output:
func NewProcess ¶
NewProcess creates a new process descriptor
func (*Process) Address ¶
Address returns networkk and address that fits the use of either net.Dial or net.Listen
func (*Process) Config ¶
Config generates an minimalistic config ini file in *ini.File format. You may then use SaveTo(path) to save it
func (*Process) SaveConfig ¶
SaveConfig generates config file according to the process attributes
func (*Process) SetDatadir ¶
SetDatadir sets default config values according with reference to the folder prefix
Equals to running these 3 statements:
process.PidFile = prefix + "/" + proc.Name ".pid" process.ErrorLog = prefix + "/" + proc.Name ".error_log" process.Listen = prefix + "/" + proc.Name ".sock"