简体   繁体   English

init.d脚本到systemd参数问题

[英]Init.d script to systemd problem with parameters

I am trying to upgrade my init.d script called "myService" to systemd .The init.d script has 1 parameter which decides what to do, with the following switch case:我正在尝试将名为“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 

In order to upgrade to systemd I create myService.service file in systemd and set in the properties of the file on ExecuteStart and ExecuteStop to execute the init.d file with parameter start or stop,now I can do : systemctl start myService.service ,however if I want to invoke the filter option I am not allowed to do systemctl filter myService .service since "filter" is not valid option for systemctl .Any suggestions how can I overcome this?为了升级到 systemd,我在 systemd 中创建了myService.service文件,并在 ExecuteStart 和 ExecuteStop 上的文件属性中设置以使用参数 start 或 stop 执行 init.d 文件,现在我可以这样做: systemctl start myService.service ,但是,如果我想调用filter选项,则不允许执行systemctl filter myService .service 因为“过滤器”不是 systemctl 的有效选项。有什么建议可以克服这个问题吗?

This scheme does not fit within systemd responsibilities as a service manager, such as (but not limited to):此方案不适合作为服务经理的systemd职责,例如(但不限于):

  • running services (eg starting, stopping, etc.)运行服务(例如启动、停止等)
  • the configuration of the above (eg which system level to run in)上面的配置(例如在哪个系统级别运行)
  • providing information on the status of a service提供有关服务状态的信息
  • declaring the dependencies and the handling between the various services声明各种服务之间的依赖关系和处理

Although you did not provide information on the implementation of the service, it seems that the filter mode is an application/server specific action.虽然您没有提供有关服务实现的信息,但似乎filter模式是特定于应用程序/服务器的操作。 Moreover, it's not clearly described what happens when the service is stopped and filter is issued.此外,它没有清楚地描述停止服务和发布filter时会发生什么。

So, keeping in mind the separation of concerns, I'd suggest using systemd to control the start and stop of your service, but use whatever IPC ( D-Bus , sockets , signals , etc.) that service is using to trigger the filter operation.因此,请记住关注点的分离,我建议使用 systemd 来控制服务的启动和停止,但使用服务用于触发filter任何 IPC( D-Bussocketssignals等)手术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM