mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
f86b6fc746
Summary: When you run 'eden start' without systemd integration, edenfs writes startup logs to the terminal to let users know that stuff is happening: ``` $ eden start Starting edenfs (dev build), pid 2792025 Opening local RocksDB store... Opened RocksDB store in 0.95 seconds. Remounting 1 mount points... Successfully remounted /data/users/strager/fbsource-dev Started edenfs (pid 2792025) Logs available at /data/users/strager/.eden-dev/logs/edenfs.log ``` These startup logs are also used by various tests (especially 'eden restart's tests). Make the same thing happen when running 'eden start' with systemd integration, improving the user experience and making some tests work: ``` $ EDEN_EXPERIMENTAL_SYSTEMD=1 \ ./buck-out/gen/eden/cli/eden.par start \ --daemon-binary "${PWD}/buck-out/gen/eden/fs/service/edenfs" Starting edenfs (dev build), pid 2800760 Opening local RocksDB store... Opened RocksDB store in 0.693 seconds. Remounting 1 mount points... Successfully remounted /data/users/strager/fbsource-dev Started edenfs (pid 2800760) ``` Reviewed By: wez Differential Revision: D13241979 fbshipit-source-id: de79b714e42b690fdab7c21d9add46bc2da35328
88 lines
3.1 KiB
Desktop File
88 lines
3.1 KiB
Desktop File
# 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]
|
|
Environment=EDENFS_EXECUTABLE_PATH=/usr/local/bin/edenfs
|
|
Environment=EDENFS_EXTRA_ARGUMENTS=
|
|
Environment=EDENFS_SYSTEM_CONFIG_DIR=/etc/eden
|
|
Environment=EDENFS_USER_CONFIG_DIR=%h/.edenrc
|
|
|
|
EnvironmentFile=-%f/systemd.conf
|
|
|
|
Environment=EDENFS_CONFIG_DIR=%f
|
|
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; \
|
|
\
|
|
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 "$${@}"; \
|
|
else \
|
|
exec /usr/bin/sudo -- "$${EDENFS_EXECUTABLE_PATH}" "$${@}"; \
|
|
fi; \
|
|
}; \
|
|
\
|
|
exec_edenfs_as_root \
|
|
--configPath "$${EDENFS_USER_CONFIG_DIR}" \
|
|
--edenDir "$${EDENFS_CONFIG_DIR}" \
|
|
--edenfs \
|
|
--etcEdenDir "$${EDENFS_SYSTEM_CONFIG_DIR}" \
|
|
--experimentalSystemd \
|
|
--foreground \
|
|
--startupLogPath "$${EDENFS_STARTUP_LOG}" \
|
|
$${EDENFS_EXTRA_ARGUMENTS}; \
|
|
'
|
|
|
|
NotifyAccess=all
|
|
Type=notify
|
|
|
|
NoNewPrivileges=false
|
|
|
|
[Install]
|