diff --git a/community/server/pom.xml b/community/server/pom.xml index d47c07732a4c0..80f2f1b98f397 100644 --- a/community/server/pom.xml +++ b/community/server/pom.xml @@ -352,12 +352,9 @@ ${neo4j-server.mainClass} test - - - org.neo4j.config.file - ${basedir}/neo4j-home/conf/neo4j.conf - - + + --config-dir=${basedir}/neo4j-home/conf + diff --git a/community/server/src/main/java/org/neo4j/server/ServerBootstrapper.java b/community/server/src/main/java/org/neo4j/server/ServerBootstrapper.java index 45668f8673a5b..1f4b2b7967ce5 100644 --- a/community/server/src/main/java/org/neo4j/server/ServerBootstrapper.java +++ b/community/server/src/main/java/org/neo4j/server/ServerBootstrapper.java @@ -41,9 +41,6 @@ import static java.lang.String.format; -import static org.neo4j.server.configuration.ServerSettings.SERVER_CONFIG_FILE; -import static org.neo4j.server.configuration.ServerSettings.SERVER_CONFIG_FILE_KEY; - public abstract class ServerBootstrapper implements Bootstrapper { public static final int OK = 0; @@ -154,8 +151,7 @@ private static LogProvider setupLogging() private Config createConfig( Log log, File file, Pair[] configOverrides ) throws IOException { - File standardConfigFile = new File( System.getProperty( SERVER_CONFIG_FILE_KEY, SERVER_CONFIG_FILE ) ); - return new ConfigLoader( this::settingsClasses ).loadConfig( file, standardConfigFile, log, configOverrides ); + return new ConfigLoader( this::settingsClasses ).loadConfig( file, log, configOverrides ); } private void addShutdownHook() diff --git a/community/server/src/main/java/org/neo4j/server/ServerCommandLineArgs.java b/community/server/src/main/java/org/neo4j/server/ServerCommandLineArgs.java index ae03bbe30fac7..3c9ca7084f295 100644 --- a/community/server/src/main/java/org/neo4j/server/ServerCommandLineArgs.java +++ b/community/server/src/main/java/org/neo4j/server/ServerCommandLineArgs.java @@ -41,7 +41,7 @@ */ public class ServerCommandLineArgs { - private static final String CONFIG_DIR_ARG = "config-dir"; + public static final String CONFIG_DIR_ARG = "config-dir"; private final Args args; private final Pair[] configOverrides; diff --git a/community/server/src/main/java/org/neo4j/server/configuration/ConfigLoader.java b/community/server/src/main/java/org/neo4j/server/configuration/ConfigLoader.java index c8480ab1d9a0d..413306beea6bf 100644 --- a/community/server/src/main/java/org/neo4j/server/configuration/ConfigLoader.java +++ b/community/server/src/main/java/org/neo4j/server/configuration/ConfigLoader.java @@ -50,28 +50,26 @@ public ConfigLoader( List> settingsClasses ) this( settings -> settingsClasses ); } - public Config loadConfig( File configFile, File legacyConfigFile, Log log, Pair... configOverrides ) + public Config loadConfig( File configFile, Log log, Pair... configOverrides ) { if ( log == null ) { throw new IllegalArgumentException( "log cannot be null " ); } - HashMap settings = calculateSettings( configFile, legacyConfigFile, log, configOverrides ); + HashMap settings = calculateSettings( configFile, log, configOverrides ); Config config = new Config( settings, settingsClasses.calculate( settings ) ); config.setLogger( log ); return config; } - private HashMap calculateSettings( File configFile, File legacyConfigFile, Log log, - Pair[] configOverrides ) + private HashMap calculateSettings( File config, Log log, Pair[] configOverrides ) { HashMap settings = new HashMap<>(); - if ( configFile != null && configFile.exists() ) + if ( config != null && config.exists() ) { - settings.putAll( loadFromFile( log, configFile ) ); + settings.putAll( loadFromFile( log, config ) ); } - settings.putAll( loadFromFile( log, legacyConfigFile ) ); settings.putAll( toMap( configOverrides ) ); overrideEmbeddedDefaults( settings ); return settings; diff --git a/community/server/src/main/java/org/neo4j/server/configuration/ServerSettings.java b/community/server/src/main/java/org/neo4j/server/configuration/ServerSettings.java index 7240f578ce310..50b03a79876c0 100644 --- a/community/server/src/main/java/org/neo4j/server/configuration/ServerSettings.java +++ b/community/server/src/main/java/org/neo4j/server/configuration/ServerSettings.java @@ -58,16 +58,6 @@ @Description("Settings used by the server configuration") public interface ServerSettings { - /** - * Key for the configuration file system property. - */ - String SERVER_CONFIG_FILE_KEY = "org.neo4j.config.file"; - - /** - * Default path for the configuration file. The path should always be get/set using System.property. - */ - String SERVER_CONFIG_FILE = "conf/neo4j.conf"; - @Description("Maximum request header size") @Internal Setting maximum_request_header_size = diff --git a/community/server/src/test/java/org/neo4j/server/configuration/ConfigLoaderTest.java b/community/server/src/test/java/org/neo4j/server/configuration/ConfigLoaderTest.java index fbf3256b9e213..1a453d04d69a5 100644 --- a/community/server/src/test/java/org/neo4j/server/configuration/ConfigLoaderTest.java +++ b/community/server/src/test/java/org/neo4j/server/configuration/ConfigLoaderTest.java @@ -62,7 +62,7 @@ public void shouldProvideAConfiguration() throws IOException .build(); // when - Config config = configLoader.loadConfig( null, configFile, log ); + Config config = configLoader.loadConfig( configFile, log ); // then assertNotNull( config ); @@ -77,7 +77,7 @@ public void shouldUseSpecifiedConfigFile() throws Exception .build(); // when - Config testConf = configLoader.loadConfig( null, configFile, log ); + Config testConf = configLoader.loadConfig( configFile, log ); // then final String EXPECTED_VALUE = "bar"; @@ -94,7 +94,7 @@ public void shouldAcceptDuplicateKeysWithSameValue() throws IOException .build(); // when - Config testConf = configLoader.loadConfig( null, configFile, log ); + Config testConf = configLoader.loadConfig( configFile, log ); // then assertNotNull( testConf ); @@ -119,7 +119,7 @@ public void shouldFindThirdPartyJaxRsPackages() throws IOException } // when - Config config = configLoader.loadConfig( null, file, log ); + Config config = configLoader.loadConfig( file, log ); // then List thirdpartyJaxRsPackages = config.get( ServerSettings.third_party_packages ); @@ -138,7 +138,7 @@ public void shouldRetainRegistrationOrderOfThirdPartyJaxRsPackages() throws IOEx .build(); // when - Config config = configLoader.loadConfig( null, configFile, log ); + Config config = configLoader.loadConfig( configFile, log ); // then List thirdpartyJaxRsPackages = config.get( ServerSettings.third_party_packages ); @@ -157,7 +157,7 @@ public void shouldWorkFineWhenSpecifiedConfigFileDoesNotExist() File nonExistentConfigFile = new File( "/tmp/" + System.currentTimeMillis() ); // When - Config config = configLoader.loadConfig( null, nonExistentConfigFile, log ); + Config config = configLoader.loadConfig( nonExistentConfigFile, log ); // Then assertNotNull( config ); diff --git a/community/server/src/test/java/org/neo4j/server/helpers/CommunityServerBuilder.java b/community/server/src/test/java/org/neo4j/server/helpers/CommunityServerBuilder.java index 678c7ea861a89..fb9eb188f97b4 100644 --- a/community/server/src/test/java/org/neo4j/server/helpers/CommunityServerBuilder.java +++ b/community/server/src/test/java/org/neo4j/server/helpers/CommunityServerBuilder.java @@ -103,7 +103,7 @@ public CommunityNeoServer build() throws IOException final File configFile = buildBefore(); Log log = logProvider.getLog( getClass() ); - Config config = new ConfigLoader( CommunityBootstrapper.settingsClasses ).loadConfig( null, configFile, log ); + Config config = new ConfigLoader( CommunityBootstrapper.settingsClasses ).loadConfig( configFile, log ); return build( configFile, config, GraphDatabaseDependencies.newDependencies().userLogProvider( logProvider ) .monitors( new Monitors() ) ); } diff --git a/enterprise/server-enterprise/pom.xml b/enterprise/server-enterprise/pom.xml index ee4e919e7d504..9284003ab09b4 100644 --- a/enterprise/server-enterprise/pom.xml +++ b/enterprise/server-enterprise/pom.xml @@ -195,12 +195,9 @@ ${neo4j-server.mainClass} test - - - org.neo4j.config.file - ${basedir}/neo4j-home/conf/neo4j.conf - - + + --config-dir=${basedir}/neo4j-home/conf + diff --git a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/ArbiterBootstrapperIT.java b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/ArbiterBootstrapperIT.java index 1dc9ad78d62ca..d1d08794b5c14 100644 --- a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/ArbiterBootstrapperIT.java +++ b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/ArbiterBootstrapperIT.java @@ -52,7 +52,8 @@ import org.neo4j.kernel.impl.util.Dependencies; import org.neo4j.kernel.lifecycle.LifeSupport; import org.neo4j.kernel.monitoring.Monitors; -import org.neo4j.server.configuration.ServerSettings; +import org.neo4j.server.ServerCommandLineArgs; +import org.neo4j.server.configuration.ConfigLoader; import org.neo4j.server.enterprise.functional.DumpPortListenerOnNettyBindFailure; import org.neo4j.test.InputStreamAwaiter; import org.neo4j.test.ProcessStreamHandler; @@ -177,23 +178,23 @@ public void after() throws Exception life.shutdown(); } - private File configFile( Map config ) throws IOException + private File writeConfig( Map config ) throws IOException { - File configFile = new File( directory, "config-file" ); + File configFile = new File( directory, ConfigLoader.DEFAULT_CONFIG_FILE_NAME ); store( config, configFile ); - return configFile; + return directory; } private void startAndAssertJoined( Integer expectedAssignedPort, Map config ) throws Exception { Map localCopy = new HashMap<>( config ); localCopy.put( GraphDatabaseSettings.auth_store.name(), Files.createTempFile( "auth", "" ).toString() ); - File configFile = configFile( localCopy ); + File configDir = writeConfig( localCopy ); CountDownLatch latch = new CountDownLatch( 1 ); AtomicInteger port = new AtomicInteger(); clients[0].addClusterListener( joinAwaitingListener( latch, port ) ); - boolean arbiterStarted = startArbiter( configFile, latch ); + boolean arbiterStarted = startArbiter( configDir, latch ); if ( expectedAssignedPort == null ) { assertFalse( format( "Should not be able to start arbiter given config file:%s", config ), arbiterStarted ); @@ -219,13 +220,13 @@ public void joinedCluster( InstanceId member, URI memberUri ) }; } - private boolean startArbiter( File configFile, CountDownLatch latch ) throws Exception + private boolean startArbiter( File configDir, CountDownLatch latch ) throws Exception { Process process = null; ProcessStreamHandler handler = null; try { - process = startArbiterProcess( configFile ); + process = startArbiterProcess( configDir ); new InputStreamAwaiter( process.getInputStream() ).awaitLine( START_SIGNAL, 20, SECONDS ); handler = new ProcessStreamHandler( process, false, "", IGNORE_FAILURES ); handler.launch(); @@ -258,14 +259,14 @@ private boolean startArbiter( File configFile, CountDownLatch latch ) throws Exc } } - private Process startArbiterProcess( File configFile ) throws Exception + private Process startArbiterProcess( File configDir ) throws Exception { List args = new ArrayList<>( asList( "java", "-cp", getProperty( "java.class.path" ) ) ); - if ( configFile != null ) + args.add( ArbiterBootstrapperTestProxy.class.getName() ); + if ( configDir != null ) { - args.add( "-D" + ServerSettings.SERVER_CONFIG_FILE_KEY + "=" + configFile.getAbsolutePath() ); + args.add( format( "--%s=%s", ServerCommandLineArgs.CONFIG_DIR_ARG, configDir ) ); } - args.add( ArbiterBootstrapperTestProxy.class.getName() ); return getRuntime().exec( args.toArray( new String[args.size()] ) ); } diff --git a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/jmx/ServerManagementTest.java b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/jmx/ServerManagementTest.java index 29933b7d3b1b7..0e1c4f95a485d 100644 --- a/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/jmx/ServerManagementTest.java +++ b/enterprise/server-enterprise/src/test/java/org/neo4j/server/enterprise/jmx/ServerManagementTest.java @@ -58,7 +58,7 @@ public void shouldBeAbleToRestartServer() throws Exception String dataDirectory1 = baseDir.directory( "data1" ).getAbsolutePath(); String dataDirectory2 = baseDir.directory( "data2" ).getAbsolutePath(); - Config config = new ConfigLoader( CommunityBootstrapper.settingsClasses ).loadConfig( null, + Config config = new ConfigLoader( CommunityBootstrapper.settingsClasses ).loadConfig( EnterpriseServerBuilder .server() .withDefaultDatabaseTuning() diff --git a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java index 69dd824799f50..4d43d79589935 100644 --- a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java +++ b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIntegrationTest.java @@ -67,10 +67,9 @@ import org.neo4j.kernel.lifecycle.LifecycleException; import org.neo4j.register.Register.DoubleLongRegister; import org.neo4j.register.Registers; -import org.neo4j.server.ServerBootstrapper; import org.neo4j.server.CommunityBootstrapper; +import org.neo4j.server.ServerBootstrapper; import org.neo4j.server.ServerTestUtils; -import org.neo4j.server.configuration.ServerSettings; import org.neo4j.test.SuppressOutput; import org.neo4j.test.TargetDirectory; import org.neo4j.test.TestGraphDatabaseFactory; @@ -209,23 +208,16 @@ public void serverDatabaseShouldStartOnOlderStoreWhenUpgradeIsEnabled() throws T props.store( writer, "" ); } + ServerBootstrapper bootstrapper = new CommunityBootstrapper(); try { - ServerBootstrapper bootstrapper = new CommunityBootstrapper(); - try - { - bootstrapper.start( configFile ); - assertTrue( bootstrapper.isRunning() ); - checkInstance( store, bootstrapper.getServer().getDatabase().getGraph() ); - } - finally - { - bootstrapper.stop(); - } + bootstrapper.start( configFile ); + assertTrue( bootstrapper.isRunning() ); + checkInstance( store, bootstrapper.getServer().getDatabase().getGraph() ); } finally { - System.clearProperty( ServerSettings.SERVER_CONFIG_FILE_KEY ); + bootstrapper.stop(); } assertConsistentStore( storeDir ); diff --git a/packaging/installer-linux/installer-rpm/src/main/resources/neo4j/neo4jd b/packaging/installer-linux/installer-rpm/src/main/resources/neo4j/neo4jd index 8174567792dc0..7619ac668b38a 100644 --- a/packaging/installer-linux/installer-rpm/src/main/resources/neo4j/neo4jd +++ b/packaging/installer-linux/installer-rpm/src/main/resources/neo4j/neo4jd @@ -29,8 +29,7 @@ CLASSPATH=`find $NEO4J_HOME -name '*.jar' | xargs echo | tr ' ' ':'` java -cp "${CLASSPATH}" \ -Dfile.encoding=UTF-8 \ - -Dorg.neo4j.config.file=conf/neo4j.conf \ - #{neo4j.mainClass} > /var/log/neo4j/neo4j.log 2>&1 & + #{neo4j.mainClass} --config-dir=conf > /var/log/neo4j/neo4j.log 2>&1 & echo $! > $PID_FILE diff --git a/packaging/neo4j-desktop/src/main/java/org/neo4j/desktop/runtime/DesktopConfigurator.java b/packaging/neo4j-desktop/src/main/java/org/neo4j/desktop/runtime/DesktopConfigurator.java index 9027988671f96..d1e6287451a83 100644 --- a/packaging/neo4j-desktop/src/main/java/org/neo4j/desktop/runtime/DesktopConfigurator.java +++ b/packaging/neo4j-desktop/src/main/java/org/neo4j/desktop/runtime/DesktopConfigurator.java @@ -54,12 +54,7 @@ public DesktopConfigurator( Installation installation, File databaseDirectory ) public void refresh() { config = new ConfigLoader( CommunityBootstrapper.settingsClasses).loadConfig( - /** Future single file, neo4j.conf or similar */ - null, - - /** Server config file */ installation.getConfigurationsFile(), - FormattedLog.toOutputStream( System.out ), /** Desktop-specific config overrides */ diff --git a/packaging/standalone/src/main/distribution/shell-scripts/bin/Neo4j-Management/Get-Java.ps1 b/packaging/standalone/src/main/distribution/shell-scripts/bin/Neo4j-Management/Get-Java.ps1 index 3931830640914..c6bc5a4d0a506 100644 --- a/packaging/standalone/src/main/distribution/shell-scripts/bin/Neo4j-Management/Get-Java.ps1 +++ b/packaging/standalone/src/main/distribution/shell-scripts/bin/Neo4j-Management/Get-Java.ps1 @@ -163,7 +163,6 @@ Function Get-Java $ClassPath="$($Neo4jServer.Home)/lib/*;$($Neo4jServer.Home)/plugins/*" $ShellArgs = @("-cp `"$($ClassPath)`""` ,'-server' ` - ,'-Dorg.neo4j.config.file=conf/neo4j.conf' ` ,'-Dlog4j.configuration=file:conf/log4j.properties' ` ,'-Dneo4j.ext.udc.source=zip-powershell' ` ,'-Dorg.neo4j.cluster.logdirectory=data/log' ` diff --git a/packaging/standalone/standalone-community/src/main/distribution/text/community/conf/neo4j-wrapper.conf b/packaging/standalone/standalone-community/src/main/distribution/text/community/conf/neo4j-wrapper.conf index d7adcfb61cac8..afe2e05d262d0 100644 --- a/packaging/standalone/standalone-community/src/main/distribution/text/community/conf/neo4j-wrapper.conf +++ b/packaging/standalone/standalone-community/src/main/distribution/text/community/conf/neo4j-wrapper.conf @@ -1,9 +1,3 @@ -#******************************************************************** -# Property file references -#******************************************************************** - -dbms.jvm.additional=-Dorg.neo4j.config.file=conf/neo4j.conf - #******************************************************************** # JVM Parameters #******************************************************************** diff --git a/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/conf/neo4j-wrapper.conf b/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/conf/neo4j-wrapper.conf index d7adcfb61cac8..afe2e05d262d0 100644 --- a/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/conf/neo4j-wrapper.conf +++ b/packaging/standalone/standalone-enterprise/src/main/distribution/text/enterprise/conf/neo4j-wrapper.conf @@ -1,9 +1,3 @@ -#******************************************************************** -# Property file references -#******************************************************************** - -dbms.jvm.additional=-Dorg.neo4j.config.file=conf/neo4j.conf - #******************************************************************** # JVM Parameters #********************************************************************