Browse Source

Gitbook Auto Published

willin 8 years ago
parent
commit
206cf9716c
2 changed files with 67 additions and 1 deletions
  1. 61 0
      basic/node/hexo.md
  2. 6 1
      experience/operation/pm2.md

+ 61 - 0
basic/node/hexo.md

@@ -332,3 +332,64 @@ git push #将代码push到raw分支上
 ```
 
 登陆相应网址进行效果查看。
+
+## 7. 附加 自动部署脚本
+
+
+在项目文件夹下新建一个`cmd`文件(文件名随意),并为其增加执行权限。
+
+```
+touch cmd
+chmod +x cmd
+```
+
+`cmd`文件源码:
+
+```bash
+#!/bin/bash
+pushd $(dirname "${0}") > /dev/null
+DIR=$(pwd -L)
+popd > /dev/null
+DATE=$(date +"%Y-%m-%d %H:%M")
+
+# get action
+ACTION=$1
+
+# help
+usage() {
+  echo "Usage: ./cmd {commit|build|clean}"
+  exit 1;
+}
+
+# start app
+commit() {
+	git add .
+	git commit -m 'Post Auto Commit'
+	git push
+}
+
+build() {
+	hexo d -g
+}
+
+# stop app
+clean() {
+	rm -rf .deploy_git
+	rm -rf public
+}
+
+case "$ACTION" in
+  commit)
+    commit
+  ;;
+  build)
+    build
+  ;;
+  clean)
+    clean
+  ;;
+  *)
+    usage
+  ;;
+esac
+```

+ 6 - 1
experience/operation/pm2.md

@@ -98,7 +98,12 @@ pm2 startup
 }
 ```
 
-如果想要根据CPU使用过高自动重启,则稍微麻烦点,需要自己写一个脚本监控。
+`PM2`是一个很好的工具,提供了`max-memory-restart`内存溢出重启的功能。
+
+但美中不足的是,没有CPU限制重启的功能。
+
+同时,也无法进行远程手动重启。但好在,PM2提供了JSON格式列表输出,让我们可以自己去写一些守护进程,或者整合到已有的运维管理系统中。
+
 
 ```bash
 pm2 jlist