fanout icon indicating copy to clipboard operation
fanout copied to clipboard

Systemd unit file

Open gerhard-tinned opened this issue 6 years ago • 17 comments
trafficstars

Hi,

I am package fanout as rpm for CentOS 7. so far I have just used the init script. But I guess it is time to use systemd unit files.

Did you create one already I can use?

Are you interested in a pull request for the rpm spec-file?

gerhard-tinned avatar Jun 19 '19 05:06 gerhard-tinned

Sure if you could provide some rpm based packaging that would be great!

travisghansen avatar Jun 19 '19 12:06 travisghansen

I will try to provide the systemd unit file and a rpm spec file.

How do you prefer the additional files? Shall I create a pull-request with those?

gerhard-tinned avatar Jun 24 '19 18:06 gerhard-tinned

That would be great yeah. Out of curiosity can you share what you're using the server for? Its original use case was pretty small so I'm interested in knowing how it's getting used today..

travisghansen avatar Jun 24 '19 20:06 travisghansen

I use it at the moment mainly with SparkleShare (https://www.sparkleshare.org/).

I was planning to use it to communicate fail2ban events to cluster nodes, but without any authentication or basic encryption, I am not sure if it is the best solution.

All in all, I like the simplicity of it. No fancy bells and whistles. :-)

gerhard-tinned avatar Jun 25 '19 06:06 gerhard-tinned

Yeah ok I was originally working with the sparkleshare team so that makes sense.

travisghansen avatar Jun 25 '19 13:06 travisghansen

I am currently hosting the fanout Server for them.

gerhard-tinned avatar Jun 26 '19 06:06 gerhard-tinned

Yeah I was working with hbons on irc back in the day...coded a few things in the client as well..

travisghansen avatar Jun 26 '19 12:06 travisghansen

Wow, interesting.

Progress ... I have a first build with systemd unit file as el7 rpm and init script as el6 rpm.

I will try to add it in a "rpm" directory and create a pull request. Next would be SELinux police for it.

gerhard-tinned avatar Jun 26 '19 16:06 gerhard-tinned

Very good!

travisghansen avatar Jun 26 '19 17:06 travisghansen

I had some fun with ulimits and systemd.

Can you shortly explain how the logic behind the --client-limit parameter works? It seems as under some conditions, fanout tries to manipulate the ulimit on its own.

It's a bit tricky to squeeze that into a unit file when systemd is handling the user under which the daemon is running.

gerhard-tinned avatar Jun 27 '19 17:06 gerhard-tinned

It's been a looooong time :)

It looks like the extent of the integration is here: https://github.com/travisghansen/fanout/blob/master/fanout.c#L461

Looks like the extent appears to be 1 function call:

setrlimit (RLIMIT_NOFILE,&i_rlimit)

travisghansen avatar Jun 27 '19 17:06 travisghansen

Hmmm. So you calculate the required file descriptors and compare it to the currently set limit. And in case the Current Limit is not big enough, you just set it. Right?

That would definitely explain what I observed. :-)

Sent with GitHawk

gerhard-tinned avatar Jun 27 '19 21:06 gerhard-tinned

Yeah, if you set --client-limit it adds a few extra file descriptors to the limit and ensures the limit is high enough to handle the desired number of clients.

For example, if you only want to allow 5000 clients it will set the limit to 5000 + <a few extras> I don't recall exactly how the extras are added up based on features etc.

travisghansen avatar Jun 27 '19 21:06 travisghansen

Thanks for the info. I found the section in the source and it seems that you calculate a few extra file descriptors and additional ones depending on the activated feature. :) Sounds really good.

I desided to set the limit for nofile in systemd unit file to "unlimit" as it seems a bit complicated to make it configureable. Additionally I set the defaults value --client-limit to 1024 for fanout.

I did that because I create a user fanout so the fanout daemon is not permitted to set the ulimit values. That would have caused the daemon to fail. If you know of an easy way to set the LIMIT_NOFILE in a configureable way, ... please let me know.

Currently testing the rpm package and the daemon start and stop behaviour. I hope to be able to provide the rpm specific files soon as pull-request.

gerhard-tinned avatar Jul 01 '19 09:07 gerhard-tinned

Yeah this one is tricky I'd guess.

Are you using LimitNOFILE= in the unit file? If so the value should be infinity no?

I'm not sure if you can set that value to a variable via an environment file. Then let fanout sysconfig file manage both via the same variable..

travisghansen avatar Jul 01 '19 14:07 travisghansen

Yes LimitNOFILE, and sorry, yes I meant infinity.

Sent with GitHawk

gerhard-tinned avatar Jul 02 '19 08:07 gerhard-tinned

I tried to set an environment variable via the enviriment file (/etc/default/fanout) and use it with LimitNOFILE but it doesn't use the variable.

gerhard-tinned avatar Jul 02 '19 08:07 gerhard-tinned