doortts doortts 2017-01-07
data: Separate data to be maintained from installed Yona
Instead of YONA_HOME, use YONA_DATA.

If you set a YONA_DATA and run bin/yona,
conf, uploads, repos, logs will be stored at YONA_DATA folder.

eg.
YONA_DATA=/yona-data;export YONA_DATA
bin/yona

It will make easy to upgrade and backup
YONA_HOME is no longer needed.
@1b3db0cf6964cd4e4aa1d2e40f573babd89df8de
app/Global.java
--- app/Global.java
+++ app/Global.java
@@ -390,12 +390,12 @@
          * @return the path to the directory to store configuration files
          */
         static Path getDirectoryPath() {
-            return Paths.get(Config.getYobiHome(""), CONFIG_DIRNAME);
+            return Paths.get(Config.getYonaDataDir(""), CONFIG_DIRNAME);
         }
 
         boolean isExternal() throws IOException, URISyntaxException {
             return !FileUtil.isSubpathOf(getPath(), getDirectoryPath()) &&
-                   !FileUtil.isSubpathOf(getPath(), Paths.get(Config.getYobiHome()));
+                   !FileUtil.isSubpathOf(getPath(), Paths.get(Config.getYonaDataDir()));
         }
     }
 }
app/models/Attachment.java
--- app/models/Attachment.java
+++ app/models/Attachment.java
@@ -271,7 +271,7 @@
     }
 
     public static File getUploadDirectory() {
-        return new File(utils.Config.getYobiHome(), uploadDirectory);
+        return new File(utils.Config.getYonaDataDir(), uploadDirectory);
     }
 
     /**
app/playRepository/GitRepository.java
--- app/playRepository/GitRepository.java
+++ app/playRepository/GitRepository.java
@@ -961,11 +961,11 @@
     }
 
     private static File getRootDirectory() {
-        return new File(utils.Config.getYobiHome(), getRepoPrefix());
+        return new File(utils.Config.getYonaDataDir(), getRepoPrefix());
     }
 
     private static File getRootDirectoryForMerging() {
-        return new File(utils.Config.getYobiHome(), getRepoForMergingPrefix());
+        return new File(utils.Config.getYonaDataDir(), getRepoForMergingPrefix());
     }
 
     /**
app/playRepository/SVNRepository.java
--- app/playRepository/SVNRepository.java
+++ app/playRepository/SVNRepository.java
@@ -420,6 +420,6 @@
     }
 
     public static File getRootDirectory() {
-        return new File(Config.getYobiHome(), getRepoPrefix());
+        return new File(Config.getYonaDataDir(), getRepoPrefix());
     }
 }
app/utils/Config.java
--- app/utils/Config.java
+++ app/utils/Config.java
@@ -38,6 +38,7 @@
 
 public class Config {
     public static final String DEFAULT_SCHEME = "http";
+    private static final String YONA_DATA = "yona.data"; //property from java -Dyona.data option string
 
     public static void onStart() {
         Diagnostic.register(new SimpleDiagnostic() {
@@ -286,12 +287,12 @@
         return Charset.forName("UTF-8");
     }
 
-    public static String getYobiHome() {
-        return System.getProperty("yobi.home");
+    public static String getYonaDataDir() {
+        return System.getProperty(YONA_DATA);
     }
 
-    public static String getYobiHome(String defaultValue) {
-        return System.getProperty("yobi.home", defaultValue);
+    public static String getYonaDataDir(String defaultValue) {
+        return System.getProperty(YONA_DATA, defaultValue);
     }
 
     public static boolean getDisplayPrivateRepositories() {
build.sbt
--- build.sbt
+++ build.sbt
@@ -89,8 +89,12 @@
     |[ -z "$YONA_HOME" ] && YONA_HOME=$(cd "$(realpath "$(dirname "$(realpath "$0")")")/.."; pwd -P)
     |addJava "-Dyobi.home=$YONA_HOME"
     |
-    |yobi_config_file="$YONA_HOME"/conf/application.conf
-    |yobi_log_config_file="$YONA_HOME"/conf/application-logger.xml
+    |[ -z "$YONA_DATA" ] && YONA_DATA=$(cd "$(realpath "$(dirname "$(realpath "$0")")")/.."; pwd -P)
+    |addJava "-Dyona.data=$YONA_DATA"
+    |addJava "-Dapplication.home=$YONA_DATA"
+    |
+    |yobi_config_file="$YONA_DATA"/conf/application.conf
+    |yobi_log_config_file="$YONA_DATA"/conf/application-logger.xml
     |[ -f "$yobi_config_file" ] && addJava "-Dconfig.file=$yobi_config_file"
     |[ -f "$yobi_log_config_file" ] && addJava "-Dlogger.file=$yobi_log_config_file"
     |
@@ -98,7 +102,7 @@
     |""".stripMargin
 
 NativePackagerKeys.batScriptExtraDefines += """
-    | if "%JAVA_OPTS%"=="" SET JAVA_OPTS=-Duser.dir=%YONA_HOME% -Dyona.home=%YONA_HOME% -Dconfig.file=%YONA_HOME%\conf\application.conf -Dlogger.file=%YONA_HOME%\conf\application-logger.xml -DapplyEvolutions.default=true
+    | if "%JAVA_OPTS%"=="" SET JAVA_OPTS=-Duser.dir=%YONA_HOME% -Dyona.data=%YONA_DATA% -Dconfig.file=%YONA_DATA%\conf\application.conf -Dlogger.file=%YONA_DATA%\conf\application-logger.xml -DapplyEvolutions.default=true
     |""".stripMargin
 
 lazy val yobi = (project in file("."))
@@ -127,4 +131,4 @@
       )
 
 
-fork in run := true
(파일 끝에 줄바꿈 문자 없음)
+fork in run := true
conf/application-logger.xml.default
--- conf/application-logger.xml.default
+++ conf/application-logger.xml.default
@@ -3,9 +3,9 @@
     <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
 
     <appender name="ACCESS_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${application.home}/logs/access.log</file>
+        <file>${yona.data}/logs/access.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${application.home}/logs/access.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${yona.data}/logs/access.%d{yyyy-MM-dd}.log</fileNamePattern>
             <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
@@ -14,9 +14,9 @@
     </appender>
 
     <appender name="APPLICATION_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${application.home}/logs/application.log</file>
+        <file>${yona.data}/logs/application.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${application.home}/logs/application.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${yona.data}/logs/application.%d{yyyy-MM-dd}.log</fileNamePattern>
             <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
@@ -25,9 +25,9 @@
     </appender>
 
     <appender name="MAIL_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${application.home}/logs/mail.log</file>
+        <file>${yona.data}/logs/mail.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${application.home}/logs/mail.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${yona.data}/logs/mail.%d{yyyy-MM-dd}.log</fileNamePattern>
             <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
@@ -36,9 +36,9 @@
     </appender>
 
     <appender name="ROOT_LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${application.home}/logs/root.log</file>
+        <file>${yona.data}/logs/root.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${application.home}/logs/root.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${yona.data}/logs/root.%d{yyyy-MM-dd}.log</fileNamePattern>
             <maxHistory>30</maxHistory>
         </rollingPolicy>
         <encoder>
 
dev.sh (added)
+++ dev.sh
@@ -0,0 +1,10 @@
+#
+# User this restart shell just for example
+#
+PORT=9000
+YONA_DATA=.;export YONA_DATA
+act=/Users/doortts/dev/play2/activator
+
+pid=`ps -ef | grep java | grep activator-launch | awk '{print $2}'`
+kill $pid
+_JAVA_OPTIONS="-Xmx2048m -Xms1024m -Dyona.data=$YONA_DATA -DapplyEvolutions.default=true -Dhttp.port=$PORT" $act run
restart.sh
--- restart.sh
+++ restart.sh
@@ -2,9 +2,8 @@
 # User this restart shell just for example
 #
 PORT=9000
-YONA_HOME=/data/yona;export YONA_HOME
-PLAY2_HOME=/home/doortts/apps/play2
+YONA_DATA=/yona-data;export YONA_DATA
 
-pid=`fuser $PORT/tcp`
+pid=`ps -ef | grep java | grep com.typesafe.play | awk '{print $2}'`
 kill $pid
-_JAVA_OPTIONS="-Xmx2048m -Xms1024m -Dyobi.home=$YONA_HOME -Dconfig.file=$YONA_HOME/conf/application.conf -Dlogger.file=$YONA_HOME/conf/application-logger.xml"  $PLAY2_HOME/activator "start -DapplyEvolutions.default=true -Dhttp.port=$PORT"
+_JAVA_OPTIONS="-Xmx2048m -Xms1024m -Dyona.data=$YONA_DATA -DapplyEvolutions.default=true -Dhttp.port=$PORT" bin/yona
Add a comment
List