mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 18:06:25 +08:00
[java] customize path of ray.conf (#3100)
users can add custom path of ray.config by using -Dray.config=/path/to/ray.conf
This commit is contained in:
@@ -7,6 +7,7 @@ Ray will read your configurations in the following order:
|
||||
|
||||
* Java system properties: e.g., ``-Dray.home=/path/to/ray``.
|
||||
* A ``ray.conf`` file in the classpath: `example <https://github.com/ray-project/ray/blob/master/java/example.conf>`_.
|
||||
* Customise your own ``ray.conf`` path using system property ``-Dray.config=/path/to/ray.conf``
|
||||
|
||||
For all available config items and default values, see `this file <https://github.com/ray-project/ray/blob/master/java/runtime/src/main/resources/ray.default.conf>`_.
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.util.NetworkUtil;
|
||||
import org.ray.runtime.util.ResourceUtil;
|
||||
import org.ray.runtime.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -242,9 +244,16 @@ public class RayConfig {
|
||||
*/
|
||||
public static RayConfig create() {
|
||||
ConfigFactory.invalidateCaches();
|
||||
Config config = ConfigFactory.systemProperties()
|
||||
.withFallback(ConfigFactory.load(CUSTOM_CONFIG_FILE))
|
||||
.withFallback(ConfigFactory.load(DEFAULT_CONFIG_FILE));
|
||||
Config config = ConfigFactory.systemProperties();
|
||||
String configPath = System.getProperty("ray.config");
|
||||
if (StringUtil.isNullOrEmpty(configPath)) {
|
||||
LOGGER.info("Loading config from \"ray.conf\" file in classpath.");
|
||||
config = config.withFallback(ConfigFactory.load(CUSTOM_CONFIG_FILE));
|
||||
} else {
|
||||
LOGGER.info("Loading config from " + configPath + ".");
|
||||
config = config.withFallback(ConfigFactory.parseFile(new File(configPath)));
|
||||
}
|
||||
config = config.withFallback(ConfigFactory.load(DEFAULT_CONFIG_FILE));
|
||||
return new RayConfig(config);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user