Closed meglio closed 12 years ago
Thanks, very valuable. I'm new to Java at all, that is why I ask such simple questions. This is good that I can use systemProperties. Can you recommend what is the best way to do for my scenario?
I have my deployment directory not related to the user home. Example:
User home: /home/aoi Deployment: /var/www/aoi/jetty_instance/webapps/root.war
Then I have start_prod.sh like this:
#!/bin/sh
export port=$(expr $(cat base_port) + 0)
echo "Starting the 'production' Jetty process at port $port"
nohup java -Xmx$(cat ram_size) -Drun.mode=production -Djetty.port=$port -jar start.jar etc/jetty.xml >> logs/std.out 2>> logs/err.out &
echo $! > prod.pid
echo "The PID is $!"
So must I add something like -Daoi.distconf="/var/www/aoi/jetty_instance/dist.conf"
... and then something like this?
val distConfig = Configuration.systemProperties[String]("aoi.distconf")
Thanks!
In that case you have to look in environment
:
val distConfig = Configuration.environment[String]("aoi.distconf")
Another approach is to put the config file in the classpath and then access it as shown here: https://github.com/paradigmatic/Configrity/wiki/InputOutput (look for "Loading from classpath")
Thanks, I'll try environment. P.S. I do not know / do not understand what classpath is.
You will need to spend some time learning about Java basics to understand how the JVM works. For the classpath start with:
Thanks for your quick answers and links! yes, I'm spending 10+ hours a day now to dive into Java/Scala word.
I just discovered that -Dxxx parameter can be retrieved with using:
Configuration.systemProperties[String]("xxx")
(and not Configuration.environment)
Indeed. I'm sorry if you lost some time. I was sure that -D
were treated as environement variables. Unfortunately Java has environment and system properties and it's very confusing to know which thing is where. Perhaps, I will provide an unique configuration which merges both.
It's simply Java default directory. From javadoc
java.io.File
:Now a free tip: You can directly get that value with
Configrity
:The
currentDir
variable will hold the default directory name.