I have made a python script to process some data that I want to run as a service. The script is processing the data, then sleeping for a while to process new data that has been coming in.
My problem is that I want to run several instances of the service as I have a few different data source that I want to process and my script is made to handle one data source at the time.
I see a few different ways of doing this:
I could rewrite the script to handle all the data sources - this will make it unusable for ad hoc use and will also make it more difficult to update the set of data sources as it is not possible to autodiscover sources that have been added or removed, so even though it is possible, this is my least favorable option.
I could make a wrapper script in bash or python that starts scripts for the data sources I want to process. This also feels a bit kludgy.
I could make one unit file for each data source, each calling the processing script with the appropriate arguments, this will give me a number of system files, i.e. processing_ds1.system, processing_ds2.system etc. To me this feels like a possible way, unless there are some good reason not to do it.
My preferred way would be to make one system file that either can be called with arguments for each data source or starting all the instances within the system file.
So I have two alternatives:
How is it possible to use arguments with unit files? I have seen postgresql can start different versions using @, i.e
systemctl start postgres@12-main
to start the cluster 12-main. But how is this done? I am not able to find any maningful unit file for postgresql.
Is it possible and adviceable to start multiple services from one unit file?