version: "0.5"

processes:

  SSH:
    command: "/usr/sbin/sshd -D $SSHD_OPTS"
    availability:
      restart: "always"
    log_location: "/var/log/sshd.log"

  JupyterLab:
    command: "/root/miniconda3/bin/jupyter lab  --ServerApp.token=\"$PASSWORD\" --notebook-dir='/'"
    availability:
      restart: "always"    
    log_location: "/var/log/jupyterlab.log"

  VSCode:
    command: "/usr/bin/code-server --auth password --bind-addr 0.0.0.0:8080  --locale=\"zh-cn\""
    availability:
      restart: "always"
    log_location: "/var/log/codeserv.log"

  WebOSDenied:
    working_dir: "/opt/webos/api/rootPath/"
    command: "jq '.denied = \"$WEB_OS_DENIED\"' start_config.json > tmp.json && mv tmp.json start_config.json"

  WebOSPass:
    working_dir: "/opt/webos/api/rootPath/"
    command: "jq -n '{username: \"root\", password: \"$PASSWORD\"}' > systemPwd.json "

  WebOSinit:
    command: "if ! sqlite3 --version  &> /dev/null ;then apt update && apt install -y sqlite3 ;fi"

  WebOSCacheClean:
    command: "rm -rf /opt/webos/api/rootPath/cache && sqlite3 /opt/webos/api/rootPath/sqlite/71d9e44ce7a3ff6e7c9a194a525c7dcc.db \"DELETE FROM sys_user_login;\" && sqlite3 /opt/webos/api/rootPath/sqlite/71d9e44ce7a3ff6e7c9a194a525c7dcc.db \"DELETE FROM sys_log;\""

  WebOS:
    working_dir: "/home/suanba"
    command: "cd /home/suanba && java -Dfile.encoding=UTF-8 --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.https=ALL-UNNAMED -javaagent:/opt/webos/api/webos.jar -XX:+UseG1GC -Xms128m -jar /opt/webos/api/webos.jar"
    log_location: "/var/log/webos.log"
    availability:
      restart: "always" 
    depends_on:
      WebOSDenied:
        condition: process_completed_successfully    
      WebOSPass:
        condition: process_completed_successfully      

  CronRootStoage:
    command: "bash /etc/suanba-script/cron-root-stoage.sh"
    availability:
      restart: "always"
      backoff_seconds: 30
      max_restarts: 0
    log_location: "/var/log/cron-storage.log"
