以下步骤需要root权限
1、写一个开机自动执行的脚本,如topology_service_start.sh,比如
#!/bin/bash
#chkconfig: 12345 90 10
#description: start topology service
dhclient
vmhgfs-fuse .host:/ /mnt/hgfs
mongod -f /root/topology/Config/mongodb.cfg
cd /root/topology/;nohup /root/miniconda3/bin/gunicorn -c /root/topology/Config/gunicorn.py PcapMain:server &
这个sh脚本有一些坑需要注意:
1)需要具备第二行和第三行的内容,chkconfig才能识别;
2)如果要执行的命令不在/usr/bin等位置,需要写上绝对路径,比如上面的最后一行,由于gunicorn命令位于miniconda3中,如果不写绝对路径,最后一行将不会执行。同理,如果是python脚本的话,也需要写全python所在的路径。
2、将脚本复制到/etc/init.d中,chmod +x topology_service_start.sh
3、chkconfig --add topology_service_start.sh
4、chkconfig topology_service_start.sh on