需要密码的
- #!/usr/bin/expect
- set timeout 3
- spawn MySQL.server start
- echo "mysql 服务启动成功!"
- spawn sh /Users/conan/Documents/tools/apache-tomcat/bin/shutdown.sh
- spawn sh /Users/conan/Documents/tools/apache-tomcat/bin/startup.sh
- echo "jenkins 服务启动成功!"
- spawn sudo uwsgi --INI /Users/conan/vir_env/AutoTest/uwsgi.INI
- expect "*password:"
- send "conan\r"
- interact
- spawn sudo nginx -c /Users/conan/vir_env/AutoTest/nginx.conf
- expect "*password:"
- send "conan\r"
- interact
运行时, 不要加 sh xx.sh, 直接运行 xx.sh(详情请见: https://blog.csdn.net/weixin_34364071/article/details/92454604)
不需要密码
- start.sh
- #!/bin/bash
- # 启动 Fasterweb
- echo -e "启动 FasterWeb"
- cd /home/conan/conan-ta/FasterWeb/
- nohup NPM run build>> /home/shared/log/NPM.log 2>&1 &
- # 启动 FasterRunner
- echo -e "启动 FasterRunner"
- cd /home/conan/conan-ta/FasterRunner/
- nohup python3 manage.py runserver 0.0.0.0:9000>> /home/shared/log/django.log 2>&1 &
- # 使用默认的 celery.py 启动
- echo -e "启动 celery beat"
- cd /home/conan/conan-ta/FasterRunner/
- nohup python3 manage.py celery beat -l info>> /Users/zd/Documents/FasterRunner/logs/beat.log 2>&1 &
- # 使用默认的 celery.py 启动
- echo -e "启动 celery work"
- cd /home/conan/conan-ta/FasterRunner/
- celery multi start w1 -A FasterRunner -l info --logfile=/Users/zd/Documents/FasterRunner/logs/worker.log 2>&1 &
- stop.sh
- #!/bin/bash
- # kill django pid
- echo -e "shutting down django pid"
- pids=$(ps aux | grep "python" | grep "runserver" | awk '{print $2}')
- for pid in $pids
- do
- kill -9 $pid
- done
- # kill celery beat pid
- echo -e "shutting down celery beat pid"
- pids=$(ps aux | grep "celery" | grep "FasterRunner" | awk '{print $2}')
- for pid in $pids
- do
- kill -9 $pid
- done
来源: http://www.bubuko.com/infodetail-3414765.html