Documentation ¶
Index ¶
- 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) 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 ¶
This section is empty.
Types ¶
type Process ¶
type Process struct { // 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/gophpfpm" ) var username, basepath, pathToPhpFpm string func main() { process := gophpfpm.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 = basepath + "/phpfpm.pid" process.ErrorLog = basepath + "/phpfpm.error_log" process.Listen = basepath + "/phpfpm.sock"
Click to show internal directories.
Click to hide internal directories.