Isilon / isilon_data_insights_connector

Connector to fetch stats from OneFS and push them to InfluxDB/Grafana
MIT License
74 stars 36 forks source link

How to convert to a service #59

Open stacka1 opened 5 years ago

stacka1 commented 5 years ago

How to you convert the collector to a service?

I put together this file under /lib/systemd/system/ but things are working as expected....any advise?

[Unit] Description=Isilon SDK for Grafana After=influxdb.service Requires=influxdb.service StartLimitIntervalSec=350

[Service] Type=simple Restart=always Restart=on-failure RestartSec=30 User=root ExecStart=/root/start-sdk.sh [Install] WantedBy=multi-user.target

fr3man1 commented 5 years ago

I think, that. you cannot convert this daemon-already isi_data_connecto because it uses a module called daemons and then detaches itself from parent pid. In default isi_data_connector there are three execution types : start, stop, restart, but if you look in isi_data_insights_d.py, then there is a daemons.run(), which lets you start a script, without detaching, so you must introduce the run execution type. Check args.action in isi_data_insights_d.py;. if still unclear, let me know.

tenortim commented 4 years ago

Yes, as written, the code already turns itself into a daemon. It would not be difficult to add support for the collector to run in the foreground, but I believe you can already use it under systemd as a service, provided you set the Type to "forking" instead of simple:

If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main service process, and the service manager will consider the unit started when the parent process exits. This is the behavior of traditional UNIX services. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can reliably identify the main process of the service. systemd will proceed with starting follow-up units as soon as the parent process exits.