- 论坛徽章:
- 10
|
回复 1# cattiger
据悉,systemd采用并行启动方式,服务之间依赖关系也类似于 rpm包一样,我也是菜鸟,共同研究下。
我觉得思路这样,服务的启动依赖于单元,各单元间有依赖,可否研究一下,在某个服务启动的时候做某些事情(比如你说的挂载内存盘)。
cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
如上面例子红字字段表示为该服务在网络服务后面启动,httpd当然得有网络了启动才有意义,所以就这么定义了,那么我们可不可以在服务启动前给它加上相应的东西呢?
话说起来容易,做起来也许就不容易了,你可以找找相关得资料研究下systemd的单元是如何工作的,以及如何自定义。
希望可以帮到你。
|
|