diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | cmd/rr-php/LICENSE | 202 | ||||
-rw-r--r-- | cmd/rr-php/cmd/root.go | 82 | ||||
-rw-r--r-- | cmd/rr-php/cmd/serve.go | 51 | ||||
-rw-r--r-- | cmd/rr-php/main.go | 23 | ||||
-rw-r--r-- | composer.json | 2 | ||||
-rw-r--r-- | config.go | 8 | ||||
-rw-r--r-- | config_test.go | 6 | ||||
-rw-r--r-- | errors.go | 32 | ||||
-rw-r--r-- | errors_test.go (renamed from job_error_test.go) | 0 | ||||
-rw-r--r-- | job_error.go | 10 | ||||
-rw-r--r-- | php/Exceptions/RoadRunnerException.php (renamed from source/Exceptions/RoadRunnerException.php) | 0 | ||||
-rw-r--r-- | php/Worker.php (renamed from source/Worker.php) | 0 | ||||
-rw-r--r-- | php/tests/broken.php (renamed from tests/broken.php) | 0 | ||||
-rw-r--r-- | php/tests/client.php (renamed from tests/client.php) | 0 | ||||
-rw-r--r-- | php/tests/delay.php (renamed from tests/delay.php) | 0 | ||||
-rw-r--r-- | php/tests/echo.php (renamed from tests/echo.php) | 0 | ||||
-rw-r--r-- | php/tests/error.php (renamed from tests/error.php) | 0 | ||||
-rw-r--r-- | php/tests/failboot.php (renamed from tests/failboot.php) | 0 | ||||
-rw-r--r-- | php/tests/head.php (renamed from tests/head.php) | 0 | ||||
-rw-r--r-- | php/tests/pid.php (renamed from tests/pid.php) | 0 | ||||
-rw-r--r-- | php/tests/slow-client.php (renamed from tests/slow-client.php) | 0 | ||||
-rw-r--r-- | php/tests/stop.php (renamed from tests/stop.php) | 0 | ||||
-rw-r--r-- | pipe_factory_test.go | 20 | ||||
-rw-r--r-- | pool.go | 4 | ||||
-rw-r--r-- | router.go | 149 | ||||
-rw-r--r-- | socket_factory_test.go | 34 | ||||
-rw-r--r-- | static_pool.go | 25 | ||||
-rw-r--r-- | static_pool_test.go | 32 | ||||
-rw-r--r-- | worker_test.go | 24 |
30 files changed, 617 insertions, 89 deletions
@@ -69,7 +69,7 @@ while ($body = $rr->receive($context)) { } } ``` -> Check how to init relay [here](./tests/client.php). More examples can be found in tests. +> Check how to init relay [here](./php/tests/client.php). More examples can be found in tests. License: -------- diff --git a/cmd/rr-php/LICENSE b/cmd/rr-php/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/cmd/rr-php/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/rr-php/cmd/root.go b/cmd/rr-php/cmd/root.go new file mode 100644 index 00000000..dfce4399 --- /dev/null +++ b/cmd/rr-php/cmd/root.go @@ -0,0 +1,82 @@ +// Copyright © 2018 NAME HERE <EMAIL ADDRESS> +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "fmt" + "os" + "github.com/mitchellh/go-homedir" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +var cfgFile string + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "rr", + Short: "A brief description of your application", + // Uncomment the following line if your bare application + // has an action associated with it: + // Run: func(cmd *cobra.Command, args []string) { }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} + +func init() { + cobra.OnInitialize(initConfig) + + // Here you will define your flags and configuration settings. + // Cobra supports persistent flags, which, if defined here, + // will be global for your application. + rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.rr.yaml)") + + // Cobra also supports local flags, which will only run + // when this action is called directly. + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // Search config in home directory with name ".rr" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".rr") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} diff --git a/cmd/rr-php/cmd/serve.go b/cmd/rr-php/cmd/serve.go new file mode 100644 index 00000000..9540a986 --- /dev/null +++ b/cmd/rr-php/cmd/serve.go @@ -0,0 +1,51 @@ +// Copyright © 2018 NAME HERE <EMAIL ADDRESS> +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spiral/roadrunner" + "os/exec" + "log" + "time" +) + +func init() { + rootCmd.AddCommand(&cobra.Command{ + Use: "serve", + Run: serveHandler, + }) +} + +func serveHandler(cmd *cobra.Command, args []string) { + r := roadrunner.NewRouter( + func() *exec.Cmd { + return exec.Command("php", "/Users/wolfy-j/Projects/phpapp/webroot/index.php", "rr", "pipes") + }, + roadrunner.NewPipeFactory(), + ) + + err := r.Configure(roadrunner.Config{ + NumWorkers: 1, + AllocateTimeout: time.Minute, + DestroyTimeout: time.Minute, + }) + + if err != nil { + panic(err) + } + + log.Print(r.Workers()) +} diff --git a/cmd/rr-php/main.go b/cmd/rr-php/main.go new file mode 100644 index 00000000..e78ce8b2 --- /dev/null +++ b/cmd/rr-php/main.go @@ -0,0 +1,23 @@ +// Copyright © 2018 NAME HERE <EMAIL ADDRESS> +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "github.com/spiral/roadrunner/cmd/rr-php/cmd" +) + +func main() { + cmd.Execute() +} diff --git a/composer.json b/composer.json index b72f6de1..64416814 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "Spiral\\RoadRunner\\": "source/" + "Spiral\\RoadRunner\\": "php/" } } }
\ No newline at end of file @@ -25,18 +25,18 @@ type Config struct { DestroyTimeout time.Duration } -// Valid returns error if config not valid +// Valid returns error if cfg not valid func (cfg *Config) Valid() error { if cfg.NumWorkers == 0 { - return fmt.Errorf("config.NumWorkers must be set") + return fmt.Errorf("cfg.NumWorkers must be set") } if cfg.AllocateTimeout == 0 { - return fmt.Errorf("config.AllocateTimeout must be set") + return fmt.Errorf("cfg.AllocateTimeout must be set") } if cfg.DestroyTimeout == 0 { - return fmt.Errorf("config.DestroyTimeout must be set") + return fmt.Errorf("cfg.DestroyTimeout must be set") } return nil diff --git a/config_test.go b/config_test.go index 64bad7cb..f4c6246d 100644 --- a/config_test.go +++ b/config_test.go @@ -14,7 +14,7 @@ func Test_NumWorkers(t *testing.T) { err := cfg.Valid() assert.NotNil(t, err) - assert.Equal(t, "config.NumWorkers must be set", err.Error()) + assert.Equal(t, "cfg.NumWorkers must be set", err.Error()) } func Test_AllocateTimeout(t *testing.T) { @@ -25,7 +25,7 @@ func Test_AllocateTimeout(t *testing.T) { err := cfg.Valid() assert.NotNil(t, err) - assert.Equal(t, "config.AllocateTimeout must be set", err.Error()) + assert.Equal(t, "cfg.AllocateTimeout must be set", err.Error()) } func Test_DestroyTimeout(t *testing.T) { @@ -36,5 +36,5 @@ func Test_DestroyTimeout(t *testing.T) { err := cfg.Valid() assert.NotNil(t, err) - assert.Equal(t, "config.DestroyTimeout must be set", err.Error()) + assert.Equal(t, "cfg.DestroyTimeout must be set", err.Error()) } diff --git a/errors.go b/errors.go new file mode 100644 index 00000000..03aa142a --- /dev/null +++ b/errors.go @@ -0,0 +1,32 @@ +package roadrunner + +// JobError is job level error (no worker halt), wraps at top +// of error context +type JobError []byte + +// Error converts error context to string +func (je JobError) Error() string { + return string(je) +} + +// WorkerError is worker related error +type WorkerError struct { + // Worker + Worker *Worker + + // Caused error + Caused error +} + +// Error converts error context to string +func (e WorkerError) Error() string { + return e.Caused.Error() +} + +// PoolError is pool wide error +type PoolError string + +// Error converts error context to string +func (e PoolError) Error() string { + return string(e) +} diff --git a/job_error_test.go b/errors_test.go index 9b0fa53e..9b0fa53e 100644 --- a/job_error_test.go +++ b/errors_test.go diff --git a/job_error.go b/job_error.go deleted file mode 100644 index d024ad11..00000000 --- a/job_error.go +++ /dev/null @@ -1,10 +0,0 @@ -package roadrunner - -// JobError is job level error (no worker halt), wraps at top -// of error context -type JobError []byte - -// Error converts error context to string -func (je JobError) Error() string { - return string(je) -} diff --git a/source/Exceptions/RoadRunnerException.php b/php/Exceptions/RoadRunnerException.php index fa7b8da3..fa7b8da3 100644 --- a/source/Exceptions/RoadRunnerException.php +++ b/php/Exceptions/RoadRunnerException.php diff --git a/source/Worker.php b/php/Worker.php index 5835baf2..5835baf2 100644 --- a/source/Worker.php +++ b/php/Worker.php diff --git a/tests/broken.php b/php/tests/broken.php index b1a3839e..b1a3839e 100644 --- a/tests/broken.php +++ b/php/tests/broken.php diff --git a/tests/client.php b/php/tests/client.php index 31caa410..31caa410 100644 --- a/tests/client.php +++ b/php/tests/client.php diff --git a/tests/delay.php b/php/tests/delay.php index bfde2fc4..bfde2fc4 100644 --- a/tests/delay.php +++ b/php/tests/delay.php diff --git a/tests/echo.php b/php/tests/echo.php index ba58ff30..ba58ff30 100644 --- a/tests/echo.php +++ b/php/tests/echo.php diff --git a/tests/error.php b/php/tests/error.php index ebd3418b..ebd3418b 100644 --- a/tests/error.php +++ b/php/tests/error.php diff --git a/tests/failboot.php b/php/tests/failboot.php index fa8b96f6..fa8b96f6 100644 --- a/tests/failboot.php +++ b/php/tests/failboot.php diff --git a/tests/head.php b/php/tests/head.php index 4f4e4061..4f4e4061 100644 --- a/tests/head.php +++ b/php/tests/head.php diff --git a/tests/pid.php b/php/tests/pid.php index a8cfa229..a8cfa229 100644 --- a/tests/pid.php +++ b/php/tests/pid.php diff --git a/tests/slow-client.php b/php/tests/slow-client.php index f09142b5..f09142b5 100644 --- a/tests/slow-client.php +++ b/php/tests/slow-client.php diff --git a/tests/stop.php b/php/tests/stop.php index caa485d6..caa485d6 100644 --- a/tests/stop.php +++ b/php/tests/stop.php diff --git a/pipe_factory_test.go b/pipe_factory_test.go index 9d50e47f..133bb266 100644 --- a/pipe_factory_test.go +++ b/pipe_factory_test.go @@ -7,7 +7,7 @@ import ( ) func Test_Pipe_Start(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, err := NewPipeFactory().SpawnWorker(cmd) assert.NoError(t, err) @@ -21,7 +21,7 @@ func Test_Pipe_Start(t *testing.T) { } func Test_Pipe_StartError(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") cmd.Start() w, err := NewPipeFactory().SpawnWorker(cmd) @@ -30,7 +30,7 @@ func Test_Pipe_StartError(t *testing.T) { } func Test_Pipe_PipeError(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") cmd.StdinPipe() w, err := NewPipeFactory().SpawnWorker(cmd) @@ -39,7 +39,7 @@ func Test_Pipe_PipeError(t *testing.T) { } func Test_Pipe_PipeError2(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") cmd.StdoutPipe() w, err := NewPipeFactory().SpawnWorker(cmd) @@ -48,7 +48,7 @@ func Test_Pipe_PipeError2(t *testing.T) { } func Test_Pipe_Failboot(t *testing.T) { - cmd := exec.Command("php", "tests/failboot.php") + cmd := exec.Command("php", "php/tests/failboot.php") w, err := NewPipeFactory().SpawnWorker(cmd) assert.Nil(t, w) @@ -57,7 +57,7 @@ func Test_Pipe_Failboot(t *testing.T) { } func Test_Pipe_Invalid(t *testing.T) { - cmd := exec.Command("php", "tests/invalid.php") + cmd := exec.Command("php", "php/tests/invalid.php") w, err := NewPipeFactory().SpawnWorker(cmd) assert.Error(t, err) @@ -65,7 +65,7 @@ func Test_Pipe_Invalid(t *testing.T) { } func Test_Pipe_Echo(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -84,7 +84,7 @@ func Test_Pipe_Echo(t *testing.T) { } func Test_Pipe_Broken(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "broken", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "broken", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -104,7 +104,7 @@ func Test_Pipe_Broken(t *testing.T) { func Benchmark_Pipe_SpawnWorker_Stop(b *testing.B) { f := NewPipeFactory() for n := 0; n < b.N; n++ { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := f.SpawnWorker(cmd) go func() { if w.Wait() != nil { @@ -117,7 +117,7 @@ func Benchmark_Pipe_SpawnWorker_Stop(b *testing.B) { } func Benchmark_Pipe_Worker_ExecEcho(b *testing.B) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -13,8 +13,8 @@ const ( // Pool managed set of inner worker processes. type Pool interface { - // Report all caused events to attached watcher. - Report(o func(event int, w *Worker, ctx interface{})) + // Observe all caused events to attached watcher. + Observe(o func(event int, ctx interface{})) // Exec one task with given payload and context, returns result or error. Exec(rqs *Payload) (rsp *Payload, err error) diff --git a/router.go b/router.go new file mode 100644 index 00000000..0bd402f4 --- /dev/null +++ b/router.go @@ -0,0 +1,149 @@ +package roadrunner + +import ( + "sync" + "os/exec" + "github.com/go-errors/errors" +) + +const ( + EventNewPool = 3 + EventDestroyPool = 4 +) + +type Router struct { + // observes pool events (can be attached to multiple pools at the same time) + observer func(event int, ctx interface{}) + + // worker command creator + cmd func() *exec.Cmd + + // pool behaviour + cfg Config + + // creates and connects to workers + factory Factory + + // protects pool while the switch + mu sync.Mutex + + // currently active pool instance + pool Pool +} + +// NewRouter creates new router. Make sure to call configure before the usage. +func NewRouter(cmd func() *exec.Cmd, factory Factory) *Router { + return &Router{ + cmd: cmd, + factory: factory, + } +} + +// Configure configures underlying pool and destroys it's previous version if any +func (r *Router) Configure(cfg Config) error { + r.mu.Lock() + previous := r.pool + r.mu.Unlock() + + pool, err := NewPool(r.cmd, r.factory, cfg) + if err != nil { + return err + } + + r.throw(EventNewPool, pool) + + r.mu.Lock() + + r.cfg, r.pool = cfg, pool + r.pool.Observe(r.poolObserver) + + r.mu.Unlock() + + if previous != nil { + go func(p Pool) { + r.throw(EventDestroyPool, p) + p.Destroy() + }(previous) + } + + return nil +} + +// Reset resets the state of underlying pool and rebuilds all of it's workers. +func (r *Router) Reset() error { + return r.Configure(r.cfg) +} + +// Observe attaches event watcher to the router. +func (r *Router) Observe(o func(event int, ctx interface{})) { + r.observer = o +} + +// Pool returns active pool or error. +func (r *Router) Pool() (Pool, error) { + r.mu.Lock() + defer r.mu.Unlock() + + if r.pool == nil { + return nil, errors.New("no associated pool") + } + + return r.pool, nil +} + +// Exec one task with given payload and context, returns result or error. +func (r *Router) Exec(rqs *Payload) (rsp *Payload, err error) { + pool, err := r.Pool() + if err != nil { + return nil, err + } + + return pool.Exec(rqs) +} + +// Workers returns worker list associated with the pool. +func (r *Router) Workers() (workers []*Worker) { + pool, err := r.Pool() + if err != nil { + return nil + } + + return pool.Workers() +} + +// Destroy all underlying pools and workers workers (but let them to complete the task). +func (r *Router) Destroy() { + r.mu.Lock() + defer r.mu.Unlock() + + if r.pool == nil { + return + } + + go func(p Pool) { + r.throw(EventDestroyPool, p) + p.Destroy() + }(r.pool) + + r.pool = nil +} + +// throw invokes event handler if any. +func (r *Router) throw(event int, ctx interface{}) { + if r.observer != nil { + r.observer(event, ctx) + } +} + +// Observe pools +func (r *Router) poolObserver(event int, ctx interface{}) { + if event == EventError { + if _, ok := ctx.(PoolError); ok { + // pool failure, rebuilding + r.Reset() + } + } + + // bypassing to user specified observer + r.throw(event, ctx) +} diff --git a/socket_factory_test.go b/socket_factory_test.go index d0d643af..87c8815b 100644 --- a/socket_factory_test.go +++ b/socket_factory_test.go @@ -19,7 +19,7 @@ func Test_Tcp_Start(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "tcp") + cmd := exec.Command("php", "php/tests/client.php", "echo", "tcp") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.NoError(t, err) @@ -42,7 +42,7 @@ func Test_Tcp_StartError(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") cmd.Start() w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) @@ -60,7 +60,7 @@ func Test_Tcp_Failboot(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/failboot.php") + cmd := exec.Command("php", "php/tests/failboot.php") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.Nil(t, w) @@ -78,7 +78,7 @@ func Test_Tcp_Timeout(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/slow-client.php", "echo", "tcp", "200", "0") + cmd := exec.Command("php", "php/tests/slow-client.php", "echo", "tcp", "200", "0") w, err := NewSocketFactory(ls, time.Millisecond*100).SpawnWorker(cmd) assert.Nil(t, w) @@ -96,7 +96,7 @@ func Test_Tcp_Invalid(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/invalid.php") + cmd := exec.Command("php", "php/tests/invalid.php") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.Error(t, err) @@ -113,7 +113,7 @@ func Test_Tcp_Broken(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "broken", "tcp") + cmd := exec.Command("php", "php/tests/client.php", "broken", "tcp") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { @@ -140,7 +140,7 @@ func Test_Tcp_Echo(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "tcp") + cmd := exec.Command("php", "php/tests/client.php", "echo", "tcp") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { @@ -170,7 +170,7 @@ func Test_Unix_Start(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "unix") + cmd := exec.Command("php", "php/tests/client.php", "echo", "unix") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.NoError(t, err) @@ -195,7 +195,7 @@ func Test_Unix_Failboot(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/failboot.php") + cmd := exec.Command("php", "php/tests/failboot.php") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.Nil(t, w) @@ -215,7 +215,7 @@ func Test_Unix_Timeout(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/slow-client.php", "echo", "unix", "200", "0") + cmd := exec.Command("php", "php/tests/slow-client.php", "echo", "unix", "200", "0") w, err := NewSocketFactory(ls, time.Millisecond*100).SpawnWorker(cmd) assert.Nil(t, w) @@ -235,7 +235,7 @@ func Test_Unix_Invalid(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/invalid.php") + cmd := exec.Command("php", "php/tests/invalid.php") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) assert.Error(t, err) @@ -254,7 +254,7 @@ func Test_Unix_Broken(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "broken", "unix") + cmd := exec.Command("php", "php/tests/client.php", "broken", "unix") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { @@ -283,7 +283,7 @@ func Test_Unix_Echo(t *testing.T) { t.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "unix") + cmd := exec.Command("php", "php/tests/client.php", "echo", "unix") w, err := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { @@ -311,7 +311,7 @@ func Benchmark_Tcp_SpawnWorker_Stop(b *testing.B) { f := NewSocketFactory(ls, time.Minute) for n := 0; n < b.N; n++ { - cmd := exec.Command("php", "tests/client.php", "echo", "tcp") + cmd := exec.Command("php", "php/tests/client.php", "echo", "tcp") w, _ := f.SpawnWorker(cmd) go func() { @@ -332,7 +332,7 @@ func Benchmark_Tcp_Worker_ExecEcho(b *testing.B) { b.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "tcp") + cmd := exec.Command("php", "php/tests/client.php", "echo", "tcp") w, _ := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { @@ -361,7 +361,7 @@ func Benchmark_Unix_SpawnWorker_Stop(b *testing.B) { f := NewSocketFactory(ls, time.Minute) for n := 0; n < b.N; n++ { - cmd := exec.Command("php", "tests/client.php", "echo", "unix") + cmd := exec.Command("php", "php/tests/client.php", "echo", "unix") w, _ := f.SpawnWorker(cmd) go func() { @@ -386,7 +386,7 @@ func Benchmark_Unix_Worker_ExecEcho(b *testing.B) { b.Skip("socket is busy") } - cmd := exec.Command("php", "tests/client.php", "echo", "unix") + cmd := exec.Command("php", "php/tests/client.php", "echo", "unix") w, _ := NewSocketFactory(ls, time.Minute).SpawnWorker(cmd) go func() { diff --git a/static_pool.go b/static_pool.go index c4895bf0..4e75cddc 100644 --- a/static_pool.go +++ b/static_pool.go @@ -22,7 +22,7 @@ type StaticPool struct { cmd func() *exec.Cmd // observer is optional callback to handle worker create/destruct/error events. - observer func(event int, w *Worker, ctx interface{}) + observer func(event int, ctx interface{}) // creates and connects to workers factory Factory @@ -43,7 +43,7 @@ type StaticPool struct { // NewPool creates new worker pool and task multiplexer. StaticPool will initiate with one worker. func NewPool(cmd func() *exec.Cmd, factory Factory, cfg Config) (*StaticPool, error) { if err := cfg.Valid(); err != nil { - return nil, errors.Wrap(err, "config error") + return nil, errors.Wrap(err, "cfg error") } p := &StaticPool{ @@ -70,8 +70,8 @@ func NewPool(cmd func() *exec.Cmd, factory Factory, cfg Config) (*StaticPool, er return p, nil } -// Report attaches pool event watcher. -func (p *StaticPool) Report(o func(event int, w *Worker, ctx interface{})) { +// Observe attaches pool event watcher. +func (p *StaticPool) Observe(o func(event int, ctx interface{})) { p.observer = o } @@ -139,7 +139,6 @@ func (p *StaticPool) Destroy() { wg.Add(1) go func(w *Worker) { defer wg.Done() - p.destroyWorker(w) }(w) } @@ -171,11 +170,11 @@ func (p *StaticPool) replaceWorker(w *Worker, caused interface{}) { go p.destroyWorker(w) if nw, err := p.createWorker(); err != nil { - p.throw(EventError, w, err) + p.throw(EventError, WorkerError{Worker: w, Caused: err}) if len(p.Workers()) == 0 { // possible situation when major error causes all PHP scripts to die (for example dead DB) - p.throw(EventError, nil, fmt.Errorf("all workers dead")) + p.throw(EventError, PoolError("all workers are dead")) } } else { p.free <- nw @@ -184,7 +183,7 @@ func (p *StaticPool) replaceWorker(w *Worker, caused interface{}) { // destroyWorker destroys workers and removes it from the pool. func (p *StaticPool) destroyWorker(w *Worker) { - p.throw(EventDestruct, w, nil) + p.throw(EventDestruct, w) // detaching p.muw.Lock() @@ -204,7 +203,7 @@ func (p *StaticPool) destroyWorker(w *Worker) { case <-time.NewTimer(p.cfg.DestroyTimeout).C: // failed to stop process if err := w.Kill(); err != nil { - p.throw(EventError, w, err) + p.throw(EventError, WorkerError{Worker: w, Caused: err}) } } } @@ -217,11 +216,11 @@ func (p *StaticPool) createWorker() (*Worker, error) { return nil, err } - p.throw(EventCreated, w, nil) + p.throw(EventCreated, w) go func(w *Worker) { if err := w.Wait(); err != nil { - p.throw(EventError, w, err) + p.throw(EventError, WorkerError{Worker: w, Caused: err}) } }(w) @@ -234,8 +233,8 @@ func (p *StaticPool) createWorker() (*Worker, error) { } // throw invokes event handler if any. -func (p *StaticPool) throw(event int, w *Worker, ctx interface{}) { +func (p *StaticPool) throw(event int, ctx interface{}) { if p.observer != nil { - p.observer(event, w, ctx) + p.observer(event, ctx) } } diff --git a/static_pool_test.go b/static_pool_test.go index b4069b98..a1db7c8c 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -19,7 +19,7 @@ var cfg = Config{ func Test_NewPool(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -33,7 +33,7 @@ func Test_NewPool(t *testing.T) { func Test_StaticPool_Invalid(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/invalid.php") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/invalid.php") }, NewPipeFactory(), cfg, ) @@ -44,7 +44,7 @@ func Test_StaticPool_Invalid(t *testing.T) { func Test_ConfigError(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), Config{ AllocateTimeout: time.Second, @@ -58,7 +58,7 @@ func Test_ConfigError(t *testing.T) { func Test_StaticPool_Echo(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -79,7 +79,7 @@ func Test_StaticPool_Echo(t *testing.T) { func Test_StaticPool_Echo_NilContext(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -100,7 +100,7 @@ func Test_StaticPool_Echo_NilContext(t *testing.T) { func Test_StaticPool_Echo_Context(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "head", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "head", "pipes") }, NewPipeFactory(), cfg, ) @@ -121,7 +121,7 @@ func Test_StaticPool_Echo_Context(t *testing.T) { func Test_StaticPool_JobError(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "error", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "error", "pipes") }, NewPipeFactory(), cfg, ) @@ -141,7 +141,7 @@ func Test_StaticPool_JobError(t *testing.T) { func Test_StaticPool_Broken_Replace(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "broken", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "broken", "pipes") }, NewPipeFactory(), cfg, ) @@ -150,7 +150,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) { assert.NotNil(t, p) assert.NoError(t, err) - p.Report(func(e int, w *Worker, ctx interface{}) { + p.Observe(func(e int, w *Worker, ctx interface{}) { if err, ok := ctx.(error); ok { assert.Contains(t, err.Error(), "undefined_function()") } @@ -164,7 +164,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) { func Test_StaticPool_AllocateTimeout(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "delay", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "delay", "pipes") }, NewPipeFactory(), Config{ NumWorkers: 1, @@ -196,7 +196,7 @@ func Test_StaticPool_AllocateTimeout(t *testing.T) { func Test_StaticPool_Replace_Worker(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "pid", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "pid", "pipes") }, NewPipeFactory(), Config{ NumWorkers: 1, @@ -232,7 +232,7 @@ func Test_StaticPool_Replace_Worker(t *testing.T) { // identical to replace but controlled on worker side func Test_StaticPool_Stop_Worker(t *testing.T) { p, err := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "stop", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "stop", "pipes") }, NewPipeFactory(), Config{ NumWorkers: 1, @@ -266,7 +266,7 @@ func Test_StaticPool_Stop_Worker(t *testing.T) { func Benchmark_Pool_Allocate(b *testing.B) { p, _ := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -285,7 +285,7 @@ func Benchmark_Pool_Allocate(b *testing.B) { func Benchmark_Pool_Echo(b *testing.B) { p, _ := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -300,7 +300,7 @@ func Benchmark_Pool_Echo(b *testing.B) { func Benchmark_Pool_Echo_Batched(b *testing.B) { p, _ := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), cfg, ) @@ -323,7 +323,7 @@ func Benchmark_Pool_Echo_Batched(b *testing.B) { func Benchmark_Pool_Echo_Replaced(b *testing.B) { p, _ := NewPool( - func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, + func() *exec.Cmd { return exec.Command("php", "php/tests/client.php", "echo", "pipes") }, NewPipeFactory(), Config{ NumWorkers: 1, diff --git a/worker_test.go b/worker_test.go index de11226a..e1af13c4 100644 --- a/worker_test.go +++ b/worker_test.go @@ -8,7 +8,7 @@ import ( ) func Test_GetState(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, err := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -24,7 +24,7 @@ func Test_GetState(t *testing.T) { } func Test_Echo(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -43,16 +43,16 @@ func Test_Echo(t *testing.T) { } func Test_NotStarted_String(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := newWorker(cmd) - assert.Contains(t, w.String(), "php tests/client.php echo pipes") + assert.Contains(t, w.String(), "php php/tests/client.php echo pipes") assert.Contains(t, w.String(), "inactive") assert.Contains(t, w.String(), "numExecs: 0") } func Test_String(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -60,13 +60,13 @@ func Test_String(t *testing.T) { }() defer w.Stop() - assert.Contains(t, w.String(), "php tests/client.php echo pipes") + assert.Contains(t, w.String(), "php php/tests/client.php echo pipes") assert.Contains(t, w.String(), "ready") assert.Contains(t, w.String(), "numExecs: 0") } func Test_Echo_Slow(t *testing.T) { - cmd := exec.Command("php", "tests/slow-client.php", "echo", "pipes", "10", "10") + cmd := exec.Command("php", "php/tests/slow-client.php", "echo", "pipes", "10", "10") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -85,7 +85,7 @@ func Test_Echo_Slow(t *testing.T) { } func Test_Broken(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "broken", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "broken", "pipes") w, err := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -101,7 +101,7 @@ func Test_Broken(t *testing.T) { } func Test_OnStarted(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "broken", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "broken", "pipes") assert.Nil(t, cmd.Start()) w, err := newWorker(cmd) @@ -112,7 +112,7 @@ func Test_OnStarted(t *testing.T) { } func Test_Error(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "error", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "error", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -129,7 +129,7 @@ func Test_Error(t *testing.T) { } func Test_NumExecs(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { @@ -148,7 +148,7 @@ func Test_NumExecs(t *testing.T) { } func Test_StateUpdated(t *testing.T) { - cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + cmd := exec.Command("php", "php/tests/client.php", "echo", "pipes") w, _ := NewPipeFactory().SpawnWorker(cmd) go func() { |