Remove CommandStopListener
This commit is contained in:
parent
852b285d84
commit
422e8e6f3e
|
@ -452,8 +452,5 @@ registrationService:
|
||||||
turn:
|
turn:
|
||||||
secret: secret://turn.secret
|
secret: secret://turn.secret
|
||||||
|
|
||||||
commandStopListener:
|
|
||||||
path: /example/path
|
|
||||||
|
|
||||||
linkDevice:
|
linkDevice:
|
||||||
secret: secret://linkDevice.secret
|
secret: secret://linkDevice.secret
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.whispersystems.textsecuregcm.configuration.Cdn3StorageManagerConfigur
|
||||||
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.CdnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.ClientCdnConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ClientCdnConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.ClientReleaseConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.ClientReleaseConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.CommandStopListenerConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
import org.whispersystems.textsecuregcm.configuration.DirectoryV2Configuration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DogstatsdConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DogstatsdConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.DynamoDbClientConfiguration;
|
||||||
|
@ -312,11 +311,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private MessageByteLimitCardinalityEstimatorConfiguration messageByteLimitCardinalityEstimator = new MessageByteLimitCardinalityEstimatorConfiguration(Duration.ofDays(1));
|
private MessageByteLimitCardinalityEstimatorConfiguration messageByteLimitCardinalityEstimator = new MessageByteLimitCardinalityEstimatorConfiguration(Duration.ofDays(1));
|
||||||
|
|
||||||
@Valid
|
|
||||||
@NotNull
|
|
||||||
@JsonProperty
|
|
||||||
private CommandStopListenerConfiguration commandStopListener;
|
|
||||||
|
|
||||||
@Valid
|
@Valid
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -530,10 +524,6 @@ public class WhisperServerConfiguration extends Configuration {
|
||||||
return messageByteLimitCardinalityEstimator;
|
return messageByteLimitCardinalityEstimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandStopListenerConfiguration getCommandStopListener() {
|
|
||||||
return commandStopListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinkDeviceSecretConfiguration getLinkDeviceSecretConfiguration() {
|
public LinkDeviceSecretConfiguration getLinkDeviceSecretConfiguration() {
|
||||||
return linkDevice;
|
return linkDevice;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.configuration;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
public record CommandStopListenerConfiguration(@NotNull String path) {
|
|
||||||
|
|
||||||
}
|
|
|
@ -70,8 +70,6 @@ public abstract class AbstractSinglePassCrawlAccountsCommand extends Environment
|
||||||
|
|
||||||
final int segments = Objects.requireNonNull(namespace.getInt(SEGMENT_COUNT));
|
final int segments = Objects.requireNonNull(namespace.getInt(SEGMENT_COUNT));
|
||||||
|
|
||||||
environment.lifecycle().manage(new CommandStopListener(configuration.getCommandStopListener()));
|
|
||||||
|
|
||||||
logger.info("Crawling accounts with {} segments and {} processors",
|
logger.info("Crawling accounts with {} segments and {} processors",
|
||||||
segments,
|
segments,
|
||||||
Runtime.getRuntime().availableProcessors());
|
Runtime.getRuntime().availableProcessors());
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2023 Signal Messenger, LLC
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.workers;
|
|
||||||
|
|
||||||
import io.dropwizard.lifecycle.Managed;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.whispersystems.textsecuregcm.configuration.CommandStopListenerConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When {@link Managed#stop()} is called, writes to a configured file path
|
|
||||||
* <p>
|
|
||||||
* Useful for coordinating process termination via a shared file-system, such as a Kubernetes volume mount.
|
|
||||||
*/
|
|
||||||
public class CommandStopListener implements Managed {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CommandStopListener.class);
|
|
||||||
|
|
||||||
private final String path;
|
|
||||||
|
|
||||||
CommandStopListener(CommandStopListenerConfiguration config) {
|
|
||||||
this.path = config.path();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop() {
|
|
||||||
try {
|
|
||||||
try (FileWriter writer = new FileWriter(path)) {
|
|
||||||
writer.write("stopped");
|
|
||||||
}
|
|
||||||
} catch (final IOException e) {
|
|
||||||
logger.error("Failed to open file {}", path, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,10 +52,6 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
|
||||||
final WhisperServerConfiguration configuration) throws Exception {
|
final WhisperServerConfiguration configuration) throws Exception {
|
||||||
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
|
||||||
final CommandStopListener commandStopListener = new CommandStopListener(configuration.getCommandStopListener());
|
|
||||||
try {
|
|
||||||
commandStopListener.start();
|
|
||||||
|
|
||||||
final UUID aci = UUID.fromString(namespace.getString("uuid").trim());
|
final UUID aci = UUID.fromString(namespace.getString("uuid").trim());
|
||||||
final List<Byte> deviceIds = namespace.getList("deviceIds");
|
final List<Byte> deviceIds = namespace.getList("deviceIds");
|
||||||
|
|
||||||
|
@ -73,8 +69,5 @@ public class UnlinkDeviceCommand extends EnvironmentCommand<WhisperServerConfigu
|
||||||
System.out.format("Removing device %s::%d\n", aci, deviceId);
|
System.out.format("Removing device %s::%d\n", aci, deviceId);
|
||||||
deps.accountsManager().removeDevice(account, deviceId).join();
|
deps.accountsManager().removeDevice(account, deviceId).join();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
commandStopListener.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue