diff --git a/README.md b/README.md index 42527ab..dff0922 100644 --- a/README.md +++ b/README.md @@ -50,37 +50,3 @@ yarn build 网页侧边栏的目录是在`docs/.vuepress/config.js`文件中定义的,具体定义方法可以查询VuePress官方文档 [VuePress主题-默认主题配置-侧边栏](https://vuepress.vuejs.org/zh/theme/default-theme-config.html#%E4%BE%A7%E8%BE%B9%E6%A0%8F) - -### DevOps - -`deploy`目录是使用PHP的workerman框架实现的简单自动部署程序,自动部署的实际执行程序是`auto_build.sh`脚本。 - -当正确配置了GIT服务器的WebHook,正确配置并启动了deploy服务后,即可实现当仓库的master分支被push后自动更新并编译本项目。 - -#### 自动部署的原理 - -GIT服务器的WebHook -> deploy服务 -> auth_build.sh - -#### deploy启动方式 - -```sh -cd deploy -cp .env.example .env -## 根据实际情况修改.env文件内容 -composer install -php start.php start -d -``` - -> 需要开放程序所在服务器的8787端口,或者做一个反向代理到8787端口的http站点。 - -#### 定义WebHook - -要实现自动拉新部署,还需要在GIT服务器上对仓库创建推送事件的WebHook的钩子URL,就是GIT服务器可以访问到的deploy服务url地址,比如`http://192.168.0.8:8787`。 - -#### 全自动安装脚本 - -可以通过执行`install.sh`脚本实现编译文档项目、启动钩子服务、实现自动构建、定期清理僵尸锁等一系统动作的全自动执行。 - -```sh -sh install.sh -``` diff --git a/auto_build.sh b/auto_build.sh deleted file mode 100644 index fa87e39..0000000 --- a/auto_build.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -log_file="auto_build.log" -lock_file="auto_build.lock" -timeout=600 # 超时时间,单位为秒 - -# 记录日志函数 -log() { - echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$$] $1" >> "$log_file" -} - -# 记录开始执行日志 -log "start" - -# 检查是否有其他进程正在执行 -while [ -f "$lock_file" ]; do - another_pid=$(cat "$lock_file") - log "另一个进程[$another_pid]正在执行,等待中……" - sleep 5 - timeout=$((timeout - 1)) - if [ "$timeout" -le 0 ]; then - log "等待超时,退出" - exit 1 - fi -done - -# 创建锁文件 -echo $$ > "$lock_file" - -# 执行git pull -execute() { - log "$1" - result=$(eval "$1" 2>&1) - log "$result" -} - -# 执行git pull -execute "git pull" - -# 检查git pull执行结果 -if [ $? -eq 0 ]; then - # git pull执行成功,执行yarn install - execute "yarn install" - - # 检查yarn install执行结果 - if [ $? -eq 0 ]; then - # yarn install执行成功,执行yarn build - execute "yarn build" - - # 检查yarn build执行结果 - if [ $? -ne 0 ]; then - # yarn build执行失败,异常退出 - log "yarn build执行失败" - rm "$lock_file" - exit 1 - fi - execute "rm -rf /www/wwwroot/book.wandoubaba.com/*" - execute "cp dist/* /www/wwwroot/book.wandoubaba.com/ -r" - else - # yarn install执行失败,异常退出 - log "yarn install执行失败" - rm "$lock_file" - exit 1 - fi -else - # git pull执行失败,异常退出 - log "git pull执行失败" - rm "$lock_file" - exit 1 -fi - -# 记录完成执行日志 -log "done" - -# 删除锁文件并正常退出 -rm "$lock_file" -exit 0 diff --git a/auto_cleaner.sh b/auto_cleaner.sh deleted file mode 100644 index a753bfc..0000000 --- a/auto_cleaner.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -log_file="auto_cleaner.log" -lock_dir="${1:-./}" -lock_file="${lock_dir}auto_build.lock" -timeout=600 # 超时时间,单位为秒 - -# 记录日志函数 -log() { - echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$log_file" -} - -# 拼接锁文件路径 -lock_file="${lock_dir}auto_build.lock" - -# 判断锁文件是否存在 -if [ -f "$lock_file" ]; then - # 获取锁文件中的进程ID - pid=$(cat "$lock_file") - - # 判断系统中是否有该进程 - if ps -p "$pid" >/dev/null; then - # 判断进程名称是否包含auto_build.sh - process_name=$(ps -o comm= -p "$pid") - if [[ "$process_name" == *"auto_build.sh"* ]]; then - log "进程[$pid]异常,释放$lock_file" - rm "$lock_file" - else - log "进程[$pid]验证正常" - fi - else - log "进程[$pid]异常,释放$lock_file" - rm "$lock_file" - fi -else - log "未发现$lock_file" -fi diff --git a/deploy/.env.example b/deploy/.env.example deleted file mode 100644 index 47bdca3..0000000 --- a/deploy/.env.example +++ /dev/null @@ -1,3 +0,0 @@ -WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com" -BRANCH = "master" -GIT_URL = "git@git.wandoubaba.com:wandoubaba/knowledge.git" diff --git a/deploy/composer.json b/deploy/composer.json deleted file mode 100644 index 996a077..0000000 --- a/deploy/composer.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "require": { - "workerman/workerman": "^4.1", - "vlucas/phpdotenv": "^5.4", - "monolog/monolog": "^2.9" - } -} diff --git a/deploy/composer.lock b/deploy/composer.lock deleted file mode 100644 index 002944b..0000000 --- a/deploy/composer.lock +++ /dev/null @@ -1,741 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "6357126a1380521e0a5719dce93ce048", - "packages": [ - { - "name": "graham-campbell/result-type", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "a878d45c1914464426dc94da61c9e1d36ae262a8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/a878d45c1914464426dc94da61c9e1d36ae262a8", - "reference": "a878d45c1914464426dc94da61c9e1d36ae262a8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.28 || ^9.5.21" - }, - "type": "library", - "autoload": { - "psr-4": { - "GrahamCampbell\\ResultType\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "An Implementation Of The Result Type", - "keywords": [ - "Graham Campbell", - "GrahamCampbell", - "Result Type", - "Result-Type", - "result" - ], - "support": { - "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", - "type": "tidelift" - } - ], - "time": "2022-07-30T15:56:11+00:00" - }, - { - "name": "monolog/monolog", - "version": "2.9.1", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f259e2b15fb95494c83f52d3caad003bbf5ffaa1", - "reference": "f259e2b15fb95494c83f52d3caad003bbf5ffaa1", - "shasum": "" - }, - "require": { - "php": ">=7.2", - "psr/log": "^1.0.1 || ^2.0 || ^3.0" - }, - "provide": { - "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", - "doctrine/couchdb": "~1.0@dev", - "elasticsearch/elasticsearch": "^7 || ^8", - "ext-json": "*", - "graylog2/gelf-php": "^1.4.2 || ^2@dev", - "guzzlehttp/guzzle": "^7.4", - "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", - "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpspec/prophecy": "^1.15", - "phpstan/phpstan": "^0.12.91", - "phpunit/phpunit": "^8.5.14", - "predis/predis": "^1.1 || ^2.0", - "rollbar/rollbar": "^1.3 || ^2 || ^3", - "ruflin/elastica": "^7", - "swiftmailer/swiftmailer": "^5.3|^6.0", - "symfony/mailer": "^5.4 || ^6", - "symfony/mime": "^5.4 || ^6" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", - "ext-mbstring": "Allow to work properly with unicode symbols", - "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", - "ext-openssl": "Required to send log messages using SSL", - "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "https://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "https://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ], - "support": { - "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.9.1" - }, - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], - "time": "2023-02-06T13:44:46+00:00" - }, - { - "name": "phpoption/phpoption", - "version": "1.9.1", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dd3a383e599f49777d8b628dadbb90cae435b87e", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": true - }, - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "PhpOption\\": "src/PhpOption/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh" - }, - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "support": { - "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", - "type": "tidelift" - } - ], - "time": "2023-02-25T19:38:58+00:00" - }, - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "vlucas/phpdotenv", - "version": "v5.4.1", - "source": { - "type": "git", - "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/264dce589e7ce37a7ba99cb901eed8249fbec92f", - "reference": "264dce589e7ce37a7ba99cb901eed8249fbec92f", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "ext-pcre": "*", - "graham-campbell/result-type": "^1.0.2", - "php": "^7.1.3 || ^8.0", - "phpoption/phpoption": "^1.8", - "symfony/polyfill-ctype": "^1.23", - "symfony/polyfill-mbstring": "^1.23.1", - "symfony/polyfill-php80": "^1.23.1" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "ext-filter": "*", - "phpunit/phpunit": "^7.5.20 || ^8.5.21 || ^9.5.10" - }, - "suggest": { - "ext-filter": "Required to use the boolean validator." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.4-dev" - } - }, - "autoload": { - "psr-4": { - "Dotenv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://github.com/vlucas" - } - ], - "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", - "keywords": [ - "dotenv", - "env", - "environment" - ], - "support": { - "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.4.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", - "type": "tidelift" - } - ], - "time": "2021-12-12T23:22:04+00:00" - }, - { - "name": "workerman/workerman", - "version": "v4.1.10", - "source": { - "type": "git", - "url": "https://github.com/walkor/workerman.git", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.0" - }, - "suggest": { - "ext-event": "For better performance. " - }, - "type": "library", - "autoload": { - "psr-4": { - "Workerman\\": "./" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "walkor", - "email": "walkor@workerman.net", - "homepage": "http://www.workerman.net", - "role": "Developer" - } - ], - "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.", - "homepage": "http://www.workerman.net", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "email": "walkor@workerman.net", - "forum": "http://wenda.workerman.net/", - "issues": "https://github.com/walkor/workerman/issues", - "source": "https://github.com/walkor/workerman", - "wiki": "http://doc.workerman.net/" - }, - "funding": [ - { - "url": "https://opencollective.com/workerman", - "type": "open_collective" - }, - { - "url": "https://www.patreon.com/walkor", - "type": "patreon" - } - ], - "time": "2023-05-01T02:12:20+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.0.0" -} diff --git a/deploy/start.php b/deploy/start.php deleted file mode 100644 index beed961..0000000 --- a/deploy/start.php +++ /dev/null @@ -1,48 +0,0 @@ -load(); -// 创建日志记录器 -$log = new Logger('workerman'); -// 添加日志处理程序,将日志写入文件 -$log->pushHandler(new StreamHandler(__DIR__ . '/workerman.log', Logger::INFO)); - -$worker = new Worker('http://0.0.0.0:8787'); - -$worker->onMessage = function (TcpConnection $connection, Request $request) use ($log) { - $log->info('Received POST data: ', $request->post()); - $work_dir = isset($_ENV['WORK_DIR']) ? $_ENV['WORK_DIR'] : null; - $branch = isset($_ENV['BRANCH']) ? $_ENV['BRANCH'] : null; - $git_url = isset($_ENV['GIT_URL']) ? $_ENV['GIT_URL'] : null; - $log->info('env: ' . json_encode(['work_dir' => $work_dir, 'branch' => $branch, 'git_url' => $git_url], JSON_UNESCAPED_UNICODE)); - if ($work_dir && $branch && $git_url) { - $repository = $request->post('repository'); - $log->info('repository: ', $repository); - if (is_array($repository)) { - $ssh_url = isset($repository['ssh_url']) ? $repository['ssh_url'] : null; - $clone_url = isset($repository['clone_url']) ? $repository['clone_url'] : null; - $log->info('ssh_url & clone_url: ' . json_encode(['ssh_url' => $ssh_url, 'clone_url' => $clone_url], JSON_UNESCAPED_UNICODE)); - if ($git_url === $ssh_url || $git_url === $clone_url) { - chdir($work_dir); - shell_exec("sh auto_build.sh > /dev/null &"); - $connection->send("finished\n"); - $connection->close(); - return; - } - } - } - $connection->send("done\n"); - $connection->close(); -}; - -// 运行worker -Worker::runAll(); diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 07de238..3662131 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,7 +1,7 @@ module.exports = { title: "PHP程序员的FreeSWITCH开发文档", description: "一个PHP程序在做FreeSWITCH相关的应用开发时积累的技术文档", - dest: "../dist", + dest: "dist", base: "/", plugins: ["@vuepress/back-to-top"], head: [ diff --git a/install.sh b/install.sh deleted file mode 100644 index 03a1718..0000000 --- a/install.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - -# 获取当前脚本所在目录路径 -work_dir=$(dirname $(readlink -f "$0")) - -# 字义install.log文件路径 -log_file="$work_dir/install.log" - -# 定义deploy目录路径 -deploy_dir="$work_dir/deploy" - -# 定时清理脚本 -cleaner_script="auto_cleaner.sh" - -# 编译脚本 -build_script="auto_build.sh" - -# 定时任务命令 -cron_command="sh $work_dir/$cleaner_script $work_dir/" - -# 检查install.lock文件是否存在 -if [ -f "$work_dir/install.lock" ]; then - install_time=$(cat "$work_dir/install.lock") - echo "项目已在$install_time完成安装,如需重新安装,可以手动删除install.lock文件后再尝试执行安装脚本" - exit 1 -fi - -# 创建install.lock文件 -current_time=$(date +"%Y-%m-%d %H:%M:%S") -echo "$current_time" >"$work_dir/install.lock" - -# 检查.env文件是否存在 -env_file="$deploy_dir/.env" -if [ -f "$env_file" ]; then - echo "[$(date +"%Y-%m-%d %H:%M:%S")] .env文件已存在,跳过创建" >>"$log_file" -else - # 创建.env文件 - branch=$(git branch --show-current) - git_url=$(git remote -v | grep fetch | awk '{print $2}') - echo "WORK_DIR = \"$work_dir\"" >"$env_file" - echo "BRANCH = \"$branch\"" >>"$env_file" - echo "GIT_URL = \"$git_url\"" >>"$env_file" - echo "[$(date +"%Y-%m-%d %H:%M:%S")] .env文件创建成功" >>"$log_file" -fi - -# 进入deploy目录 -cd "$deploy_dir" - -start_script="start.php" -# 先尝试停止一次应用 -php "$start_script" stop -stop_result=$? -echo "[$(date +"%Y-%m-%d %H:%M:%S")] 先尝试执行php $start_script stop,结果:$stop_result" | tee -a "$log_file" - -# 执行composer install -yes | composer install -install_result=$? -if [ $install_result -ne 0 ]; then - echo "[$(date +"%Y-%m-%d %H:%M:%S")] PHP环境可能异常,自动拉新功能很可能不会生效" | tee -a "$log_file" -fi -echo "[$(date +"%Y-%m-%d %H:%M:%S")] 执行composer install,结果:$install_result" | tee -a "$log_file" - -# 启动应用 -if [ -f "$start_script" ]; then - php "$start_script" start -d - start_result=$? - echo "[$(date +"%Y-%m-%d %H:%M:%S")] 执行php $start_script start -d,结果:$start_result" | tee -a "$log_file" - if [ $start_result -ne 0 ]; then - echo "[$(date +"%Y-%m-%d %H:%M:%S")] PHP环境可能异常,自动拉新功能不会生效" | tee -a "$log_file" - else - echo "[$(date +"%Y-%m-%d %H:%M:%S")] deploy服务启动成功" | tee -a "$log_file" - fi -else - echo "[$(date +"%Y-%m-%d %H:%M:%S")] start.php文件不存在,代码不完整,自动拉新功能不会生效" | tee -a "$log_file" -fi - -# 退出deploy目录 -cd .. - -# 检查auto_cleaner.sh文件和定时任务 -auto_cleaner_script="$work_dir/auto_cleaner.sh" -if [ ! -f "$auto_cleaner_script" ]; then - echo "[$(date +"%Y-%m-%d %H:%M:%S")] 未找到$auto_cleaner_script文件,跳过" | tee -a "$log_file" -else - existing_cron=$(crontab -l | grep -F "$cron_command") - if [ -n "$existing_cron" ]; then - echo "[$(date +"%Y-%m-%d %H:%M:%S")] auto_cleaner.sh任务已存在,跳过" | tee -a "$log_file" - else - ( - crontab -l 2>/dev/null - echo "*/10 * * * * $cron_command" - ) | crontab - - echo "[$(date +"%Y-%m-%d %H:%M:%S")] auto_cleaner.sh任务安装成功" | tee -a "$log_file" - fi -fi - -# 执行编译脚本 -sh $build_script - -echo "[$(date +"%Y-%m-%d %H:%M:%S")] 安装完毕,在$log_file中可以查看完整的安装日志" | tee -a "$log_file" - -# 退出 -exit 0