mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
4363456fb8
Summary: When Eden is competing with hundreds of build processes using about the same amount of RAM, it's less painful for the OOM killer to kill the compilers, not the edenfs daemon. Bias its OOM score a little. Reviewed By: wez Differential Revision: D17701071 fbshipit-source-id: 5ee1078e78e5aa6251692944ca12d9a892f86a6f
104 lines
3.7 KiB
Desktop File
104 lines
3.7 KiB
Desktop File
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# systemd service unit file for EdenFS.
|
|
# systemd: https://freedesktop.org/wiki/Software/systemd/
|
|
# EdenFS: https://our.intern.facebook.com/intern/wiki/Eden/
|
|
|
|
[Unit]
|
|
Description=EdenFS FUSE filesystem
|
|
|
|
[Service]
|
|
LimitNOFILE=1048576
|
|
OOMScoreAdjust=-20
|
|
Environment=EDENFS_EXECUTABLE_PATH=/usr/local/libexec/eden/edenfs
|
|
Environment=EDENFS_EXTRA_ARGUMENTS=
|
|
Environment=EDENFS_SYSTEM_CONFIG_DIR=/etc/eden
|
|
Environment=EDENFS_USER_CONFIG_DIR=%h/.edenrc
|
|
Environment=EDENFS_CLI_PATH=/usr/local/bin/edenfsctl
|
|
|
|
EnvironmentFile=-%f/systemd.conf
|
|
|
|
Environment=EDENFS_CONFIG_DIR=%f
|
|
Environment=EDENFS_LOG_DIR=%f/logs
|
|
Environment=EDENFS_LOG_FILE=%f/logs/edenfs.log
|
|
Environment=EDENFS_STARTUP_LOG=%f/startup.log
|
|
Environment=EDENFS_USER_ID=%U
|
|
|
|
# Some important escaping rules for how the quoted argument of 'sh -c' within
|
|
# ExecStart is interpreted by systemd:
|
|
#
|
|
# * '\' followed by a newline is replaced with ' ' (a space). (You *must* escape
|
|
# newlines with '\'.) A leading '\' escapes '\'. [1]
|
|
# * '\' followed by "'" (a single quote) is replaced with single quote. [2]
|
|
# * '$' followed by '$' is replaced with a single '$'. [3]
|
|
# * '%' followed by '%' is replaced with a single '%'. [4]
|
|
#
|
|
# Recommendations:
|
|
#
|
|
# * End each physical line with ' \' (a space followed by a backslash). [1]
|
|
# * Escape "'" (a single quote) using '\'. Use "can\'t", not "can't". Prefer
|
|
# using double quotes instead of single quotes. [2]
|
|
# * Escape '$' using '$'. Use '$${var}', not '$var' or '${var}'. [3]
|
|
# * Escape '%' using '%'. Use '100%% cool', not '100% cool'. [4]
|
|
# * Terminate commands with ';', if appropriate, instead of a newline. [5]
|
|
#
|
|
# References:
|
|
#
|
|
# [1] https://www.freedesktop.org/software/systemd/man/systemd.syntax.html
|
|
# https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/shared/conf-parser.c#L354-L365
|
|
#
|
|
# [2] https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/basic/extract-word.c#L68
|
|
# https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/basic/escape.c#L48-L51
|
|
#
|
|
# [3] https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/basic/env-util.c#L526-L542
|
|
#
|
|
# [4] https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/core/unit-printf.c#L217
|
|
# https://github.com/systemd/systemd/blob/66a5b5ce9b991327d594f7b635de16999ca54093/src/shared/specifier.c#L48-L49
|
|
#
|
|
# [5] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
|
|
|
|
ExecStart=/bin/sh -c ' \
|
|
set -e; \
|
|
set -u; \
|
|
\
|
|
/bin/mkdir -p -- "$${EDENFS_LOG_DIR}"; \
|
|
exec >>"$${EDENFS_LOG_FILE}" 2>&1; \
|
|
\
|
|
newline="$$(printf "\\nx")"; \
|
|
newline="$${newline::-1}"; \
|
|
\
|
|
`# Split EDENFS_EXTRA_ARGUMENTS on newlines, not whitespace.`; \
|
|
IFS="$${newline}"; \
|
|
\
|
|
exec_edenfs_as_root() { \
|
|
if [ "$${EDENFS_USER_ID}" -eq 0 ]; then \
|
|
exec "$${EDENFS_EXECUTABLE_PATH}" --allowRoot "$${@}"; \
|
|
elif [ -u "$${EDENFS_EXECUTABLE_PATH}" ]; then \
|
|
exec "$${EDENFS_EXECUTABLE_PATH}" "$${@}"; \
|
|
else \
|
|
exec /usr/bin/sudo -- "$${EDENFS_EXECUTABLE_PATH}" "$${@}"; \
|
|
fi; \
|
|
}; \
|
|
\
|
|
exec_edenfs_as_root \
|
|
--configPath "$${EDENFS_USER_CONFIG_DIR}" \
|
|
--edenDir "$${EDENFS_CONFIG_DIR}" \
|
|
--edenfs \
|
|
--edenfsctlPath "$${EDENFS_CLI_PATH}" \
|
|
--etcEdenDir "$${EDENFS_SYSTEM_CONFIG_DIR}" \
|
|
--experimentalSystemd \
|
|
--foreground \
|
|
--startupLogPath "$${EDENFS_STARTUP_LOG}" \
|
|
$${EDENFS_EXTRA_ARGUMENTS}; \
|
|
'
|
|
|
|
NotifyAccess=all
|
|
Type=notify
|
|
|
|
NoNewPrivileges=false
|
|
|
|
[Install]
|