zoukankan      html  css  js  c++  java
  • systemd的程序自启动脚本编写

    以FreeSWITCH的自启动脚本为例。

    一、 编写freeswitch.service文件

     1 [Unit]
     2 Description=FreeSWITCH
     3 After=syslog.target network.target
     4 After=postgresql.service mysqld.service
     5 
     6 [Service]
     7 User=root
     8 EnvironmentFile=/etc/systemd/freeswitch.conf
     9 # RuntimeDirectory is not yet supported in CentOS 7. A workaround is to use /etc/tmpfiles.d/freeswitch.conf
    10 #RuntimeDirectory=/run/freeswitch
    11 #RuntimeDirectoryMode=0750
    12 WorkingDirectory=/usr/local/freeswitch/run
    13 PIDFile=/usr/local/freeswitch/run/freeswitch.pid
    14 ExecStart=/usr/bin/freeswitch -nc -nf $FREESWITCH_PARAMS
    15 ExecReload=/usr/bin/kill -HUP $MAINPID
    16
    17 [Install]
    18 WantedBy=multi-user.target

    二、 freeswitch.service的文件路径

    可能会和具体的Linux版本有关系,给出ubuntu的例子:

    /lib/systemd/system/

    三、 编写步骤一中声明的配置文件

    1. 文件路径

    /etc/systemd/freeswitch.conf

    2. 文件内容

    1 ## Type: string
    
    2 ## Default: ""
    3 ## Config: ""
    4 ## ServiceRestart: freeswitch
    5 #
    6 # if not empty: parameters for freeswitch
    7 #
    8 FREESWITCH_PARAMS="-nonat"

    四、 自启动添加

    systemctl enable freeswitch.service

    五、 添加自启动的时候,日志提示如下

    Created symlink /etc/systemd/system/multi-user.target.wants/freeswitch.service /lib/systemd/system/freeswitch.service

    在etc/systemd/system/multi-user.target.wants/目录下生成一个freeswitch.service的链接。

  • 相关阅读:
    kaggle CTR预估
    基于大规模语料的新词发现算法【转自matix67】
    vim E437: terminal capability "cm" required
    makefile 中的符号替换($@、$^、$<、$?)
    【转】Makefile 中:= ?= += =的区别
    python urljoin问题
    python 写文件刷新缓存
    python Popen卡死问题
    nohup 日志切割
    换行和回车野史
  • 原文地址:https://www.cnblogs.com/yoyotl/p/7751677.html
Copyright © 2011-2022 走看看