init.d脚本带有参数的systemd问题

问题描述 投票:1回答:1

我正在尝试将名为“myService”的init.d脚本升级到systemd。init.d脚本有1个参数决定要做什么,使用以下开关案例:

case "$choice" in 
    "start")
        # starts service logic here
    "stop") 
        # stops service logic here
    "filter") 
        # runs some .sh file from our PC
esac 

为了升级到systemd,我在systemd中创建myService.service文件并在ExecuteStart和ExecuteStop上设置文件的属性来执行带参数start或stop的init.d文件,现在我可以这样做:systemctl start myService.service,但是如果我想调用filter选项我不允许做systemctl filter myService.service,因为“filter”不是systemctl的有效选项。任何建议我如何克服这个?

linux systemd
1个回答
1
投票

此方案不适合作为服务经理的systemd职责,例如(但不限于):

  • 运行服务(例如开始,停止等)
  • 上面的配置(例如,运行哪个系统级别)
  • 提供有关服务状态的信息
  • 声明各种服务之间的依赖关系和处理

虽然您没有提供有关服务实现的信息,但似乎filter模式是特定于应用程序/服务器的操作。此外,没有清楚地描述当服务停止并发布filter时会发生什么。

因此,请记住关注点的分离,我建议使用systemd来控制服务的启动和停止,但使用服务正在使用的任何IPC(D-Bussocketssignals等)来触发filter操作。

© www.soinside.com 2019 - 2024. All rights reserved.