## 打开终端A
```
cd ~
pyenv activate frappe
bench init sbang --frappe-path=https://gitee.com/qinyanwan/frappe
cd ~/sbang/apps/frappe/
git fetch --all --tags
git checkout tags/v13.26.0 -b v13.26.0-branch
git branch
bench build --app frappe
bench get-app https://gitee.com/phipsoft/erpnext.git
cd ~/sbang/apps/erpnext/
git fetch --all --tags
git checkout tags/v13.26.0 -b v13.26.0-branch
git branch
bench build --app erpnext
bench get-app https://gitee.com/yuzelin/erpnext_chinese.git
bench get-app https://gitee.com/yuzelin/erpnext_oob.git
bench get-app https://gitee.com/yuzelin/zelin_permission.git
bench new-site sbang13dev
bench --site sbang13dev install-app erpnext
bench --site sbang13dev install-app erpnext_chinese
bench --site sbang13dev install-app erpnext_oob
bench --site sbang13dev install-app zelin_permission
bench --site sbang13dev restore 20220424_153416-sbang13dev-database.sql.gz --with-public-files 20220424_153416-sbang13dev-files.tar --with-private-files 20220424_153416-sbang13dev-private-files.tar
```
## 打开终端B
```
screen -S sbang13dev
pyenv activate frappe
bench set-config -g developer_mode 1
bench start
```
## 回到终端A
```
bench --site sbang13dev migrate
bench --site sbang13dev list-apps
```
### 备份
```
bench --site sbang13dev backup --with-files
ls ~/sbang/sites/sbang13dev/private/backups/
```
## 开发环境
```
frappe 13.26.0 v13.26.0-branch
erpnext 13.26.0 v13.26.0-branch
erpnext_chinese 13.0.0 master
erpnext_oob 13.0.0 master
zelin_permission 0.0.1 master
```
## 新建App
```
bench new-app app_sbang
cd ~/sbang/apps/app_sbang/
git remote add origin https://e.coding.net/kirinsoar/app/app_sbang.git
git push -u origin master
bench --site sbang13dev install-app app_sbang
bench --site sbang13dev migrate
```
## git push App
```
cd ~/sbang/apps/app_sbang/
bench --site sbang13dev export-fixtures
bench --site sbang13dev export-fixtures --app app_sbang
git add .
git commit -m "export-fixtures"
git push
```
## 有时 bench start 不工作了,报错如下
```
15:29:43 system | redis_cache.1 started (pid=5556)
15:29:43 redis_cache.1 | 5563:C 25 Apr 2022 15:29:43.558 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:29:43 redis_cache.1 | 5563:C 25 Apr 2022 15:29:43.558 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=5563, just started
15:29:43 redis_cache.1 | 5563:C 25 Apr 2022 15:29:43.558 # Configuration loaded
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.559 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.560 * Running mode=standalone, port=13005.
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.560 # Server initialized
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.560 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.560 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
15:29:43 redis_cache.1 | 5563:M 25 Apr 2022 15:29:43.560 * Ready to accept connections
15:29:43 system | redis_queue.1 started (pid=5560)
15:29:43 redis_queue.1 | 5575:C 25 Apr 2022 15:29:43.563 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:29:43 redis_queue.1 | 5575:C 25 Apr 2022 15:29:43.563 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=5575, just started
15:29:43 redis_queue.1 | 5575:C 25 Apr 2022 15:29:43.563 # Configuration loaded
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 * Running mode=standalone, port=11005.
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 # Server initialized
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
15:29:43 redis_queue.1 | 5575:M 25 Apr 2022 15:29:43.564 * Ready to accept connections
15:29:43 system | redis_socketio.1 started (pid=5559)
15:29:43 redis_socketio.1 | 5569:C 25 Apr 2022 15:29:43.560 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:29:43 redis_socketio.1 | 5569:C 25 Apr 2022 15:29:43.560 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=5569, just started
15:29:43 redis_socketio.1 | 5569:C 25 Apr 2022 15:29:43.560 # Configuration loaded
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 * Running mode=standalone, port=12005.
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 # Server initialized
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
15:29:43 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:43.561 * Ready to accept connections
15:29:43 system | web.1 started (pid=5567)
15:29:43 system | worker_long.1 started (pid=5591)
15:29:43 system | worker_default.1 started (pid=5595)
15:29:43 system | socketio.1 started (pid=5566)
15:29:43 system | worker_short.1 started (pid=5593)
15:29:43 system | watch.1 started (pid=5602)
15:29:43 system | schedule.1 started (pid=5589)
15:29:43 socketio.1 | listening on *: 9005
15:29:45 system | worker_short.1 stopped (rc=2)
15:29:45 system | sending SIGTERM to redis_cache.1 (pid 5556)
15:29:45 system | sending SIGTERM to redis_socketio.1 (pid 5559)
15:29:45 system | sending SIGTERM to redis_queue.1 (pid 5560)
15:29:45 system | sending SIGTERM to web.1 (pid 5567)
15:29:45 system | sending SIGTERM to socketio.1 (pid 5566)
15:29:45 system | sending SIGTERM to watch.1 (pid 5602)
15:29:45 system | sending SIGTERM to schedule.1 (pid 5589)
15:29:45 system | sending SIGTERM to worker_long.1 (pid 5591)
15:29:45 system | sending SIGTERM to worker_default.1 (pid 5595)
15:29:45 redis_queue.1 | 5575:signal-handler (1650871785) Received SIGTERM scheduling shutdown...
15:29:45 redis_socketio.1 | 5569:signal-handler (1650871785) Received SIGTERM scheduling shutdown...
15:29:45 system | socketio.1 stopped (rc=-15)
15:29:45 system | worker_default.1 stopped (rc=-15)
15:29:45 redis_cache.1 | 5563:signal-handler (1650871785) Received SIGTERM scheduling shutdown...
15:29:45 system | web.1 stopped (rc=-15)
15:29:45 system | watch.1 stopped (rc=-15)
15:29:45 system | worker_long.1 stopped (rc=-15)
15:29:45 redis_queue.1 | 5575:M 25 Apr 2022 15:29:45.077 # User requested shutdown...
15:29:45 redis_queue.1 | 5575:M 25 Apr 2022 15:29:45.078 * Removing the pid file.
15:29:45 redis_queue.1 | 5575:M 25 Apr 2022 15:29:45.078 # Redis is now ready to exit, bye bye...
15:29:45 system | redis_queue.1 stopped (rc=-15)
15:29:45 system | schedule.1 stopped (rc=-15)
15:29:45 redis_cache.1 | 5563:M 25 Apr 2022 15:29:45.164 # User requested shutdown...
15:29:45 redis_cache.1 | 5563:M 25 Apr 2022 15:29:45.164 * Removing the pid file.
15:29:45 redis_cache.1 | 5563:M 25 Apr 2022 15:29:45.164 # Redis is now ready to exit, bye bye...
15:29:45 system | redis_cache.1 stopped (rc=-15)
15:29:45 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:45.167 # User requested shutdown...
15:29:45 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:45.167 * Removing the pid file.
15:29:45 redis_socketio.1 | 5569:M 25 Apr 2022 15:29:45.167 # Redis is now ready to exit, bye bye...
15:29:45 system | redis_socketio.1 stopped (rc=-15)
```
### 运行
```
bench setup redis
bench setup socketio
bench setup requirements
bench set-config maintenance_mode 0
```
## 当整个网站都无法访问时,有可能是防火墙关了
```
sudo iptables -t nat -P INPUT ACCEPT
sudo iptables -t nat -F
sudo iptables -P INPUT ACCEPT
sudo iptables -F
```