Skip to content

v3_EN_LinuxService

winlin edited this page Nov 7, 2019 · 21 revisions

HOME > EN(3.0) > System Service

SRS Linux Service

There are many ways to startup SRS:

  • Directly run srs at the trunk/objs, and need start again when system restart.
  • Linux service, the init.d scirpt at simple-rtmp-server/trunk/etc/init.d/srs, and user can add to linux service when linked to the /etc/init.d/srs then add as service /sbin/chkconfig --add srs.

The SRS release binary can be downloaded from release site, we can install as system service, see: Github: release or Mirror for China: release

Manual

We donot need to add to linux service to directly start SRS:

cd srs/trunk &&
./etc/init.d/srs start

or

cd srs/trunk &&
./objs/srs -c conf/srs.conf

init.d

Install and startup SRS as linux system service:

  • Build SRS: the install script will modify the INSTALL ROOT of init.d script.
  • Link to init.d: link the trunk/etc/init.d/srs to /etc/init.d/srs
  • Add to linux service: use /sbin/chkconfig for Centos.

Step1: Build and Install SRS

Intall SRS when build ok:

make && sudo make install

the install of make will install srs to the prefix dir, default to /usr/local/srs, which is specified by configure, for instance, ./configure --prefix=`pwd`/_release set the install dir to _release of current dir to use make install without sudo.

Step2: Link script to init.d:

sudo ln -sf \
    /usr/local/srs/etc/init.d/srs \
    /etc/init.d/srs

Step3:Add as linux service:

#centos 6
sudo /sbin/chkconfig --add srs

or

#ubuntu12
sudo update-rc.d srs defaults

Use init.d script

Get the status of SRS:

/etc/init.d/srs status

Start SRS:

/etc/init.d/srs start

Stop SRS:

/etc/init.d/srs stop

Restart SRS:

/etc/init.d/srs restart

Reload SRS:

/etc/init.d/srs reload

systemctl

CentOS7 use systemctl to manage services, we also need to install init.d service, then add to systemctl:

./configure && make && sudo make install &&
sudo ln -sf /usr/local/srs/etc/init.d/srs /etc/init.d/srs &&
sudo cp -f /usr/local/srs/usr/lib/systemd/system/srs.service /usr/lib/systemd/system/srs.service &&
sudo systemctl daemon-reload && sudo systemctl enable srs

Remark: We MUST copy the srs.service, or we couldn't enable the service by systemctl.

Use systemctl to start SRS:

sudo systemctl start srs

Winlin 2019.10

Welcome to SRS wiki!

SRS 5.0 wiki

Please select your language:

SRS 4.0 wiki

Please select your language:

SRS 3.0 wiki

Please select your language:

SRS 2.0 wiki

Please select your language:

SRS 1.0 wiki

Please select your language:

Clone this wiki locally