anystack-sh/porter
Composer 安装命令:
composer create-project anystack-sh/porter
包简介
Spin up your development background processes with ease.
关键字:
README 文档
README
About Porter
Porter is a command-line interface (CLI) tool that makes it easy to run background services by adding a few lines to a configuration file.
These services are managed by Supervisord, a process control system that ensures that all processes are kept up and running.
With Porter, you don't have to manually start and manage background services in multiple terminal tabs.
Instead, you can simply use the porter command to manage all of your services in a single place.
Installation
To install Porter, you can use composer or download the build manually from this repository.
composer global require anystack-sh/porter
Requirements
To use Porter you must install supervisord:
- macOS:
brew install supervisor - Linux:
apt install supervisor
If you want to use the watch feature to restart services when files change you will also need to install:
- chokidar:
npm install --global chokidar
Add your first project
In your terminal navigate to your project and run porter init to create a boilerplate porter.yml:
~/Developer/anystack: $ porter init Create porter.yml in /Users/Developer/anystack? (yes/no) [yes]: > yes Creating porter.yml boilerplate: ✔ Run "porter add" to add your product and start your services.
Modify porter.yml and add the services you want to run. In your terminal navigate to your project and run porter add:
~/Developer/anystack: $ porter add
Adding /Users/Developer/anystack: ✔
Restarting Porter: ✔
A new porter.yml has been created. This file contains all the services you want to run in the background, for example:
services: - name: Queue command: php artisan horizon processes: 3 # Optional, number of parallel processes. Defaults to 1 restart: watch: - app/Jobs - app/Mail/WelcomEmail.php - name: Vite directory: Users/developer/anystack/front-end command: npm run dev environment: FOO: "BAR" - name: Octane command: php artisan octane:start --port=8000 --no-interaction - name: Stripe command: stripe listen --forward-to localhost:8000/webhooks/stripe restart: minutes: 5
The following properties are available per command:
| Property | Description | Required |
|---|---|---|
| name | Shortname that describes your service. | Yes |
| directory | Set the working directory, defaults to porter.yml directory. | No |
| command | The command to run relative to the root of your project or custom defined directory. | Yes |
| restart | ||
| - minutes | After how many minutes the service should restart. | No |
| - watch | Restart service if files or directories are modified. | No |
| processes | Set the number of parallel processes for the service. Defaults to 1. | No |
| environment | Set custom environment variables | No |
If you have made changes to your porter.yml you can use the porter restart command to apply your changes.
Monitoring services
To monitor your services you can use the porter status command.
~/Developer/anystack: $ porter status +----------+-----------------+---------+---------------------------+ | App | Name | Status | Description | +----------+-----------------+---------+---------------------------+ | anystack | anystack-octane | RUNNING | pid 41277, uptime 0:03:29 | | anystack | anystack-queue | RUNNING | pid 41275, uptime 0:03:29 | | anystack | anystack-vite | RUNNING | pid 41276, uptime 0:03:29 | +----------+-----------------+---------+---------------------------+
Tail service logs
Basic tail usage
You can tail one or more services (unified) using the porter tail command.
This command is context-aware and will automatically ask which services you want to tail:
~/Developer/anystack: $ porter tail Which service do you want to tail?: [0] anystack-octane [1] anystack-queue [2] anystack-vite > 0,1 Use CTRL+C to stop tailing. Horizon started successfully. INFO Server running… Local: http://127.0.0.1:8000 200 GET / ... 33.38 mb 79.10 ms
Tail all available services
To automatically tail all available services, pass the --all option:
~/Developer/anystack: $ porter tail --all
Use CTRL+C to stop tailing.
Horizon started successfully.
INFO Server running…
Local: http://127.0.0.1:8000
200 GET / ... 33.38 mb 79.10 ms
Tail one or more services
You can specify one or more services that you would like to tail by passing
the --services option with a comma-separated list of service indexes or service names.
You can find the index and name of each available service by running porter tail with no arguments:
~/Developer/anystack: $ porter tail Which service do you want to tail?: [0] anystack-octane [1] anystack-queue [2] anystack-vite
The following examples reference the service names and indexes found above:
~/Developer/anystack: $ porter tail --services=0,2
~/Developer/anystack: $ porter tail --services=anystack-octane,anystack-vite
The above two commands are functionally equivalent.
~/Developer/anystack: $ porter tail --services=1
~/Developer/anystack: $ porter tail --services=anystack-queue
The above two commands are functionally equivalent.
All available commands
| Command | Description |
|---|---|
porter add |
Add current directory as a new application. |
porter remove |
Remove current application services. |
porter start |
Start all services. |
porter restart |
Restart one or multiple services. |
porter stop |
Stop all services. |
porter tail |
Tail service logs. |
Brought to you by Anystack
Anystack is the all-in-one product platform that helps you make a living by writing code. Push your code to GitHub, and we will take care of everything else. Start your adventure today.
License
Porter is open-sourced software licensed under the MIT license.
anystack-sh/porter 适用场景与选型建议
anystack-sh/porter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 680 次下载、GitHub Stars 达 530, 最近一次更新时间为 2022 年 12 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cli」 「console」 「laravel」 「supervisor」 「productivity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 anystack-sh/porter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anystack-sh/porter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 anystack-sh/porter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This class provides you with an easy-to-use interface to progress bars.
A Laravel package to retrieve data from Google Search Console
Additional artisan commands for Laravel
A table generator class for the PHP CLI.
Slim starter / Slim skeleton package to boost your development with Slim framework
Generates a trait to help ease the access of custom repo methods
统计信息
- 总下载量: 680
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 530
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-26