[Unit]
Description=3proxy tiny proxy server
Documentation=man:3proxy(8) man:3proxy.cfg(5)
After=network.target

[Service]
Type=simple
User=proxy
Group=proxy
Environment=CONFIGFILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/3proxy/3proxy.cfg
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/3proxy ${CONFIGFILE}
ExecReload=/bin/kill -SIGUSR1 $MAINPID
KillMode=process
Restart=on-failure
RestartSec=60s
# 3proxy uses one thread and two descriptors per connection (four for ftppr),
# so it reaches these limits much earlier than event driven servers. They are
# ceilings only: the actual number of connections is governed by 'maxconn' in
# the configuration file. TasksMax must be set explicitly, systemd's
# DefaultTasksMax (15% of kernel.threads-max, e.g. ~9000) otherwise caps the
# number of threads, and thus connections, regardless of LimitNPROC.
LimitNOFILE=1048576
LimitNPROC=infinity
TasksMax=infinity
RuntimeDirectory=3proxy
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
Alias=3proxy.service
