#!/bin/sh

set -e
set -o xtrace

cat > /lib/systemd/system/mongod.service << '_EOF_'
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target check-numa.service
Wants=check-numa.service
Documentation=https://docs.mongodb.org/manual

[Service]
User=mongodb
Group=mongodb
RuntimeDirectory=mongodb
EnvironmentFile=/etc/numactl.env
ExecStart=/bin/bash -c "${NUMACTL} /usr/bin/mongod --quiet --config /etc/mongod.conf"
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitRSS=infinity
LimitNPROC=64000

[Install]
WantedBy=multi-user.target
_EOF_

systemctl daemon-reload
systemctl enable mongod.service
