mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
d18ce1082e
Summary: This refactors the `edenfsctl start` command so that we more clearly split the functionality into two pieces: * Starting EdenFS as a service * Running EdenFS in the foreground In most normal situations in production the `start`, `restart`, and `stop` commands are used to manage running EdenFS as a service. In the future I believe our service management logic will start to diverge a bit more on Linux vs Mac vs Windows, and this should help isolate the service-management code a bit more cleanly. The foreground behavior is mainly only used by developers during testing and during the integration tests. Several options like `--gdb` and `--strace` are only allowed in foreground mode, and this refactoring makes that clearer. In the future we may also want to further restrict this, to allow only specifying additional custom arguments and a custom binary path when running in foreground mode. However, for now I have not updated that as I believe some of our integration tests may be exercising this behavior today. This change also cleans up some of the platform-specific code, and lets them share more of the logic to construct arguments for edenfs. With this change `edenfsctl start --foreground` now works on Windows. Reviewed By: pkaush Differential Revision: D20833244 fbshipit-source-id: 0f09d59702d8b64ca8f4fedccbc30da1c858afb4
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# 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.
|
|
|
|
# pyre-strict
|
|
|
|
import subprocess
|
|
from typing import List, Optional
|
|
|
|
from . import proc_utils_win
|
|
from .config import EdenInstance
|
|
|
|
|
|
def start_edenfs_service(cmd: List[str]) -> None:
|
|
# TODO: At the moment this isn't actually using the Windows service code
|
|
cmd_str = subprocess.list2cmdline(cmd)
|
|
proc_utils_win.create_process_shim(cmd_str)
|
|
print("EdenFS started")
|
|
|
|
|
|
def run_edenfs_foreground(cmd: List[str]) -> int:
|
|
"""Run EdenFS in the "foreground" of the user's terminal. It will log directly to
|
|
our stdout/stderr, and we'll wait for it to exit before we return.
|
|
"""
|
|
process = subprocess.Popen(cmd)
|
|
while True:
|
|
try:
|
|
return process.wait()
|
|
except KeyboardInterrupt:
|
|
# Catch the exception if the user interrupts EdenFS with Ctrl-C.
|
|
# The interrupt will have also been delivered to EdenFS, so it should shut
|
|
# down. Continue around the while loop to keep waiting for it to exit, and
|
|
# still pass through its return code.
|
|
continue
|