All Projects → kcloze → Multiprocess

kcloze / Multiprocess

🚀Easy to make the common PHP/Python/js...script change daemon and multi-process execution

Projects that are alternatives of or similar to Multiprocess

Spm
A process manager similar to systemd and foreman with stop feature, written in Go.
Stars: ✭ 44 (-70.86%)
Mutual labels:  daemon, manager, process
Sympact
🔥 Stupid Simple CPU/MEM "Profiler" for your JS code.
Stars: ✭ 439 (+190.73%)
Mutual labels:  cli, process
Fastd
🚀 A high performance PHP API framework.
Stars: ✭ 423 (+180.13%)
Mutual labels:  swoole, process
Auto Cpufreq
Automatic CPU speed & power optimizer for Linux
Stars: ✭ 843 (+458.28%)
Mutual labels:  cli, daemon
core d.js
Offload your heavy lifting to a daemon. Extracted from eslint_d.
Stars: ✭ 21 (-86.09%)
Mutual labels:  daemon, process
Laravel S
LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.
Stars: ✭ 3,479 (+2203.97%)
Mutual labels:  swoole, process
Fkill Cli
Fabulously kill processes. Cross-platform.
Stars: ✭ 6,418 (+4150.33%)
Mutual labels:  cli, process
Immortal
⭕ A *nix cross-platform (OS agnostic) supervisor
Stars: ✭ 701 (+364.24%)
Mutual labels:  daemon, process
Cliwrap
Library for running command line processes
Stars: ✭ 1,057 (+600%)
Mutual labels:  cli, process
Find Process
find process by port/pid/name etc.
Stars: ✭ 80 (-47.02%)
Mutual labels:  cli, process
Mix Phar Skeleton
Phar command line program development skeleton
Stars: ✭ 81 (-46.36%)
Mutual labels:  cli, swoole
fast-laravel
基于Swoole的高性能HTTP服务器,加速您Laravel应用程序。
Stars: ✭ 33 (-78.15%)
Mutual labels:  process, swoole
W7 Rangine Empty
软擎是基于 Php 7.2+ 和 Swoole 4.4+ 的高性能、简单易用的开发框架。支持同时在 Swoole Server 和 php-fpm 两种模式下运行。内置了 Http (Swoole, Fpm),Tcp,WebSocket,Process,Crontab服务。集成了大量成熟的组件,可以用于构建高性能的Web系统、API、中间件、基础服务等等。
Stars: ✭ 246 (+62.91%)
Mutual labels:  swoole, process
Apio
🌱 Open source ecosystem for open FPGA boards
Stars: ✭ 366 (+142.38%)
Mutual labels:  cli, manager
Swoft Im
基于swoft-cloud的微服务架构,最小化拆分粒度,PHP7、多进程、协程、异步任务、mysql连接池、redi连接池、rpc连接池、服务治理、服务注册与发现、Aop切面、全注解
Stars: ✭ 189 (+25.17%)
Mutual labels:  swoole, process
Quicssh
SSH over QUIC
Stars: ✭ 116 (-23.18%)
Mutual labels:  cli, daemon
Cli
Get a programmable email address. Automate what happens when you receive emails. It's like Zapier for devs who hate emails.
Stars: ✭ 105 (-30.46%)
Mutual labels:  cli, daemon
Procs
A modern replacement for ps written in Rust
Stars: ✭ 2,435 (+1512.58%)
Mutual labels:  cli, process
Php Msf
PHP微服务框架即Micro Service Framework For PHP
Stars: ✭ 1,764 (+1068.21%)
Mutual labels:  swoole
Lowpolify
Create low-poly art from any image 🌟🌟
Stars: ✭ 149 (-1.32%)
Mutual labels:  multiprocessing

multiprocess

  • [readme in english]
  • 基于swoole的脚本管理,用于多进程和守护进程管理;
  • 可轻松让普通脚本变守护进程和多进程执行;
  • 进程个数可配置,可以根据配置一次性执行多条命令;
  • 子进程异常退出时,主进程收到信号,自动拉起重新执行;
  • 支持子进程平滑退出,防止重启服务对业务造成影响;
  • 不限定编程语言,PHP/Python/Java/Golang/C#等脚本都可以管理

1. 场景

  • PHP/python/js等脚本需要跑一个或多个脚本消费队列/计算等任务
  • 实现脚本退出后自动拉起,防止消费队列不工作,影响业务
  • 其实supervisor可以轻松做个事情,这个只是PHP的另一种实现,不需要换技术栈

2. 流程图

流程图

3. 安装

4. 配置实例

  • 一次性执行多个命令
    'logPath'   => __DIR__ . '/log',
    'exec'      => [
        [
            'name'      => 'kcloze-test-1',
            'bin'       => '/usr/bin/php',
            'binArgs'   => [__DIR__ . '/test/test.php', 'oop', '123'],
            'workNum'   => 3,
        ],
        [
            'name'      => 'kcloze-test-2',
            'bin'       => '/usr/bin/php',
            'binArgs'   => [__DIR__ . '/test/test2.php', 'oop', '456'],
            'workNum'   => 5,
        ],
        [
            'name'      => 'kcloze-test-3',
            'bin'       => '/usr/bin/python',
            'binArgs'   => [__DIR__ . '/test/test3.py', 'oop', '369'],
            'workNum'   => 2,
        ],
    ],

5. 运行

5.1 启动

  • chmod -R u+r log/
  • php multiprocess.php start >> log/system.log 2>&1

5.2 平滑停止服务,根据子进程执行时间等待所有服务停止

  • php multiprocess.php stop

5.3 强制停止服务[慎用]

  • php multiprocess.php exit

5.4 强制重启

  • php multiprocess.php restart >> log/system.log 2>&1

5.5 监控

  • ps -ef|grep 'multi-process'

5.6 启动参数说明

NAME
      php multiprocess - manage multiprocess

SYNOPSIS
      php multiprocess -s command [options] -c config file path
          Manage multiprocess daemons.


WORKFLOWS


      help [command]
      Show this help, or workflow help for command.

      -s restart
      Stop, then start multiprocess master and workers.

      -s start 
      Start multiprocess master and workers.
      -s start -c ./config
      Start multiprocess with specail config file.


      -s stop
      Wait all running workers smooth exit, please check multiprocess status for a while.

      -s exit
      Kill all running workers and master PIDs.

6. 服务管理

启动和关闭服务,有两种方式:

6.1 php脚本(主进程挂了之后,需要手动启动)

./multiprocess.php start|stop|exit|restart

6.2 使用systemd管理(故障重启、开机自启动)

更多systemd介绍

1. 根据自己项目路径,修改 systemd/multiprocess.service
2. sudo cp -f systemd/multiprocess.service /etc/systemd/system/
3. sudo systemctl --system daemon-reload
4. 服务管理
#启动服务
sudo systemctl start multiprocess.service
#reload服务
sudo systemctl reload multiprocess.service
#关闭服务
sudo systemctl stop multiprocess.service

7. 系统状态

监控图

8. change log

2017-11-30

  • 彻底重构v2版本
  • 增加exit启动参数,默认stop等待子进程平滑退出

9. 感谢

10. 联系

qq群:141059677

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].