Type=forking 的使用
最后更新于:2022-04-02 03:49:04
[TOC]
## Type=forking 的使用
当你以 systemctl 的方式启动 bash 脚本时,可以使用此方法
如
``` ├─16463 /bin/bash /opt/im_user/im_server/im_server/im_common/start all ├─16474 /bin/bash ../upmessageserver/upmessageserver_guard ├─16482 ./UpMessageServer ├─16535 sleep 30 ├─16547 /bin/bash ../uporgserver/uporgserver_guard ├─16555 ./UpOrgServer ├─16644 sleep 30 ├─16655 /bin/bash ../uploginserver/uploginserver_guard ├─16668 sleep 30 ├─16677 /bin/bash ../upstatusserver/upstatusserver_guard ├─16685 ./UpStatusServer ├─16738 sleep 30 ├─16747 /bin/bash ../upfileserver/upfileserver_guard ├─16755 ./UpFileServer ├─16808 sleep 30 ├─16817 /bin/bash ../upgroupserver/upgroupserver_guard ├─16825 ./UpGroupServer ├─16827 sleep 30 ├─16840 /bin/bash ../uppushserver/uppushserver_guard ├─16841 sleep 3 ├─16843 /bin/bash ./uppushserver_starter ├─16848 ./UpPushServer └─16849 sleep 1 ```
';
im_server.service
启动效果 ``` [Unit] Description=login im_server [Service] Type=forking WorkingDirectory=/opt/im_user/im_server/im_server/ ExecStart=/opt/im_user/im_server/im_server/im_common/start all Restart=always RestartSec=5 Environment=LD_LIBRARY_PATH=/opt/im_user/im_server/im_server/im_common/:/opt/im_user/im_server/im_webserver/common [Install] WantedBy=multi-user.target `````` ├─16463 /bin/bash /opt/im_user/im_server/im_server/im_common/start all ├─16474 /bin/bash ../upmessageserver/upmessageserver_guard ├─16482 ./UpMessageServer ├─16535 sleep 30 ├─16547 /bin/bash ../uporgserver/uporgserver_guard ├─16555 ./UpOrgServer ├─16644 sleep 30 ├─16655 /bin/bash ../uploginserver/uploginserver_guard ├─16668 sleep 30 ├─16677 /bin/bash ../upstatusserver/upstatusserver_guard ├─16685 ./UpStatusServer ├─16738 sleep 30 ├─16747 /bin/bash ../upfileserver/upfileserver_guard ├─16755 ./UpFileServer ├─16808 sleep 30 ├─16817 /bin/bash ../upgroupserver/upgroupserver_guard ├─16825 ./UpGroupServer ├─16827 sleep 30 ├─16840 /bin/bash ../uppushserver/uppushserver_guard ├─16841 sleep 3 ├─16843 /bin/bash ./uppushserver_starter ├─16848 ./UpPushServer └─16849 sleep 1 ```