Recently used Centos7, start the manager is Systemd, feel very fun.
1, Boot automatically start
Create a new service file and put it in/usr/lib/systemd/system/
Like what:
[Unit] Description= description before= started before a service, can not be started after a service, can not [ Service]Type=simpleexecstart= command [Install ]wantedby=multi-user.target
Save As Xxx.service
Can use Systemctl enable Xxx.service (. Service can be omitted, SYSTEMD will automatically find files ending with. Service)
2. Multi-instance
A service file like [email protected] can be used to start multiple instances
such as starting multiple memcache, after installing memcache with Yum,
Will generate/etc/sysconfig/memcached files, you can copy one, named Memcached1,memcached2, etc., modify the inside of the port, do not conflict.
[email protected] is configured as follows:
[Unit]Description=Memcached before=Httpd.serviceafter=Network.target[Service]Type=Simpleenvironmentfile=-/etc/sysconfig/memcached%iexecstart=/usr/bin/memcached-u $USER-P $PORT-M $CACHESIZE-c $MAXCONN $OPTIONS[Install]Wantedby=multi-user.target
can use Systemctl start [email protected] to pass parameters, in the service file with%i to accept parameters
Systemd Starting multiple instances