kandi background
Explore Kits

nacos | easytouse dynamic service discovery | Microservice library

 by   alibaba Java Version: 2.1.0-BETA License: Apache-2.0

 by   alibaba Java Version: 2.1.0-BETA License: Apache-2.0

Download this library from

kandi X-RAY | nacos Summary

nacos is a Java library typically used in Architecture, Microservice applications. nacos has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • nacos has a medium active ecosystem.
  • It has 21883 star(s) with 9513 fork(s). There are 876 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 655 open issues and 4804 have been closed. On average issues are closed in 45 days. There are 43 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of nacos is 2.1.0-BETA
nacos Support
Best in #Microservice
Average in #Microservice
nacos Support
Best in #Microservice
Average in #Microservice

quality kandi Quality

  • nacos has 0 bugs and 0 code smells.
nacos Quality
Best in #Microservice
Average in #Microservice
nacos Quality
Best in #Microservice
Average in #Microservice

securitySecurity

  • nacos has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • nacos code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
nacos Security
Best in #Microservice
Average in #Microservice
nacos Security
Best in #Microservice
Average in #Microservice

license License

  • nacos is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
nacos License
Best in #Microservice
Average in #Microservice
nacos License
Best in #Microservice
Average in #Microservice

buildReuse

  • nacos releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • nacos saves you 92978 person hours of effort in developing the same functionality from scratch.
  • It has 103434 lines of code, 8355 functions and 1129 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
nacos Reuse
Best in #Microservice
Average in #Microservice
nacos Reuse
Best in #Microservice
Average in #Microservice
Top functions reviewed by kandi - BETA

kandi has reviewed nacos and discovered the below as its top functions. This is intended to give you an instant insight into nacos implemented functionality, and help decide if they suit your requirements.

  • Compares two arrays .
  • Receive a heartbeat from the master .
  • Get the config .
  • Gets the context .
  • Binary stream observer for request .
  • Loads the credential .
  • Attempt to match a pattern
  • apply rule .
  • Return a page of config info
  • Perform reconnect .

nacos Key Features

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

Start by the provided startup package

copy iconCopydownload iconDownload
unzip nacos-server-1.0.0.zip
cd nacos/bin 

How to extract kubernetes pod command execution result attributes

copy iconCopydownload iconDownload
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}
-----------------------
$ stat yourFileOrDirName
  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100
$ stat --printf="%n,%A,%y,%s" yourFileOrDirName
yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346
$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName
stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName
{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}

How can i change heap size when i use docker-compose and dockerfile to create a javaproject?

copy iconCopydownload iconDownload
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 ..." # but no -Xmx
#!/bin/sh
# docker-entrypoint.sh

# Set JVM memory options if set as environment variables.
if [ -n "$JVM_XMS" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS"
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX"
fi

# Then run the main container command.
exec "$@"
ENV ... \
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" \
    ...
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]         # must be JSON array form
CMD java ${JAVA_OPTS} -jar app.jar ${PARAMS} # Docker inserts `sh -c`
ENV ... \
    SERVER_PORT=8080 \
    SPRING_PROFILES_ACTIVE=prod \
    ...
CMD java $JAVA_OPTS -jar app.jar # without $PARAMS
exec java $JAVA_OPTS -jar app.jar "$@"
# if this runs `java -jar app.jar`
ENTRYPOINT ["/docker-entrypoint.sh"]
# then include additional options here -- MUST be a JSON array
CMD ["--server.port=8080", "--spring.profiles.active=prod"]
-----------------------
-docker
|
--services
|
---demo
|  |-docker-entrypoint.sh
|  |-Dockerfile
|
-docker-compose.yml
FROM openjdk:8-jdk
MAINTAINER whywhathow(whywhathow.fun@gmail.com)
ENV \
JVM_GC="+UseConcMarkSweepGC"\
JVM_XMS="128m" \
JVM_XMX="256m"  \
SERVER_PORT="8080" \
SPRING_PROFILES_ACTIVE="prod" \
NACOS_ADDR="127.0.0.1" \
JAVA_RANDOM="-Djava.security.egd=file:/dev/./urandom"
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
COPY ./*.jar /app.jar
#EXPOSE 8080
#ENTRYPOINT ["/bin/sh","-c","java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"]
# test shell
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
#!/bin/bash
# docker-entrypoint.sh
# link: https://stackoverflow.com/questions/69718900/how-can-i-change-heap-size-when-i-use-docker-compose-and-dockerfile-to-create-a
# print debug information
set -ex

#########################################################
# Set JVM memory options if set as environment variables.
#########################################################
if [ -n "${JVM_XMS}" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS "
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX "
fi
# shellcheck disable=SC1072
if [ -n "$JVM_GC" ]; then
  JAVA_OPTS="$JAVA_OPTS -XX:$JVM_GC"
fi
if [ -n "$JAVA_RANDOM" ]; then
  JAVA_OPTS="$JAVA_OPTS $JAVA_RANDOM"
fi
#########################################################
# set params
#########################################################

# shellcheck disable=SC1073
if [ -n  "$SERVER_PORT" ]; then
    PARAMS="$PARAMS --server.port=$SERVER_PORT "
fi
if [ -n  "$SPRING_PROFILES_ACTIVE" ]; then
    PARAMS="$PARAMS --spring.profiles.active=$SPRING_PROFILES_ACTIVE "
fi
if [ -n  "$NACOS_ADDR" ]; then
    PARAMS="$PARAMS --spring.cloud.nacos.server-addr=$NACOS_ADDR"
fi
if [ -n "$OTHER_PARAMS" ];  then
    PARAMS="$PARAMS $OTHER_PARAMS"
fi
# Then run the main container command.
exec  java $JAVA_OPTS -jar  app.jar $PARAMS
docker-compose up demo 
-----------------------
-docker
|
--services
|
---demo
|  |-docker-entrypoint.sh
|  |-Dockerfile
|
-docker-compose.yml
FROM openjdk:8-jdk
MAINTAINER whywhathow(whywhathow.fun@gmail.com)
ENV \
JVM_GC="+UseConcMarkSweepGC"\
JVM_XMS="128m" \
JVM_XMX="256m"  \
SERVER_PORT="8080" \
SPRING_PROFILES_ACTIVE="prod" \
NACOS_ADDR="127.0.0.1" \
JAVA_RANDOM="-Djava.security.egd=file:/dev/./urandom"
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
COPY ./*.jar /app.jar
#EXPOSE 8080
#ENTRYPOINT ["/bin/sh","-c","java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"]
# test shell
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
#!/bin/bash
# docker-entrypoint.sh
# link: https://stackoverflow.com/questions/69718900/how-can-i-change-heap-size-when-i-use-docker-compose-and-dockerfile-to-create-a
# print debug information
set -ex

#########################################################
# Set JVM memory options if set as environment variables.
#########################################################
if [ -n "${JVM_XMS}" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS "
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX "
fi
# shellcheck disable=SC1072
if [ -n "$JVM_GC" ]; then
  JAVA_OPTS="$JAVA_OPTS -XX:$JVM_GC"
fi
if [ -n "$JAVA_RANDOM" ]; then
  JAVA_OPTS="$JAVA_OPTS $JAVA_RANDOM"
fi
#########################################################
# set params
#########################################################

# shellcheck disable=SC1073
if [ -n  "$SERVER_PORT" ]; then
    PARAMS="$PARAMS --server.port=$SERVER_PORT "
fi
if [ -n  "$SPRING_PROFILES_ACTIVE" ]; then
    PARAMS="$PARAMS --spring.profiles.active=$SPRING_PROFILES_ACTIVE "
fi
if [ -n  "$NACOS_ADDR" ]; then
    PARAMS="$PARAMS --spring.cloud.nacos.server-addr=$NACOS_ADDR"
fi
if [ -n "$OTHER_PARAMS" ];  then
    PARAMS="$PARAMS $OTHER_PARAMS"
fi
# Then run the main container command.
exec  java $JAVA_OPTS -jar  app.jar $PARAMS
docker-compose up demo 
-----------------------
-docker
|
--services
|
---demo
|  |-docker-entrypoint.sh
|  |-Dockerfile
|
-docker-compose.yml
FROM openjdk:8-jdk
MAINTAINER whywhathow(whywhathow.fun@gmail.com)
ENV \
JVM_GC="+UseConcMarkSweepGC"\
JVM_XMS="128m" \
JVM_XMX="256m"  \
SERVER_PORT="8080" \
SPRING_PROFILES_ACTIVE="prod" \
NACOS_ADDR="127.0.0.1" \
JAVA_RANDOM="-Djava.security.egd=file:/dev/./urandom"
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
COPY ./*.jar /app.jar
#EXPOSE 8080
#ENTRYPOINT ["/bin/sh","-c","java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"]
# test shell
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
#!/bin/bash
# docker-entrypoint.sh
# link: https://stackoverflow.com/questions/69718900/how-can-i-change-heap-size-when-i-use-docker-compose-and-dockerfile-to-create-a
# print debug information
set -ex

#########################################################
# Set JVM memory options if set as environment variables.
#########################################################
if [ -n "${JVM_XMS}" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS "
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX "
fi
# shellcheck disable=SC1072
if [ -n "$JVM_GC" ]; then
  JAVA_OPTS="$JAVA_OPTS -XX:$JVM_GC"
fi
if [ -n "$JAVA_RANDOM" ]; then
  JAVA_OPTS="$JAVA_OPTS $JAVA_RANDOM"
fi
#########################################################
# set params
#########################################################

# shellcheck disable=SC1073
if [ -n  "$SERVER_PORT" ]; then
    PARAMS="$PARAMS --server.port=$SERVER_PORT "
fi
if [ -n  "$SPRING_PROFILES_ACTIVE" ]; then
    PARAMS="$PARAMS --spring.profiles.active=$SPRING_PROFILES_ACTIVE "
fi
if [ -n  "$NACOS_ADDR" ]; then
    PARAMS="$PARAMS --spring.cloud.nacos.server-addr=$NACOS_ADDR"
fi
if [ -n "$OTHER_PARAMS" ];  then
    PARAMS="$PARAMS $OTHER_PARAMS"
fi
# Then run the main container command.
exec  java $JAVA_OPTS -jar  app.jar $PARAMS
docker-compose up demo 
-----------------------
-docker
|
--services
|
---demo
|  |-docker-entrypoint.sh
|  |-Dockerfile
|
-docker-compose.yml
FROM openjdk:8-jdk
MAINTAINER whywhathow(whywhathow.fun@gmail.com)
ENV \
JVM_GC="+UseConcMarkSweepGC"\
JVM_XMS="128m" \
JVM_XMX="256m"  \
SERVER_PORT="8080" \
SPRING_PROFILES_ACTIVE="prod" \
NACOS_ADDR="127.0.0.1" \
JAVA_RANDOM="-Djava.security.egd=file:/dev/./urandom"
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
COPY ./*.jar /app.jar
#EXPOSE 8080
#ENTRYPOINT ["/bin/sh","-c","java  ${JAVA_OPTS} -jar app.jar ${PARAMS}"]
# test shell
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
#!/bin/bash
# docker-entrypoint.sh
# link: https://stackoverflow.com/questions/69718900/how-can-i-change-heap-size-when-i-use-docker-compose-and-dockerfile-to-create-a
# print debug information
set -ex

#########################################################
# Set JVM memory options if set as environment variables.
#########################################################
if [ -n "${JVM_XMS}" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xms$JVM_XMS "
fi
if [ -n "$JVM_XMX" ]; then
  JAVA_OPTS="$JAVA_OPTS -Xmx$JVM_XMX "
fi
# shellcheck disable=SC1072
if [ -n "$JVM_GC" ]; then
  JAVA_OPTS="$JAVA_OPTS -XX:$JVM_GC"
fi
if [ -n "$JAVA_RANDOM" ]; then
  JAVA_OPTS="$JAVA_OPTS $JAVA_RANDOM"
fi
#########################################################
# set params
#########################################################

# shellcheck disable=SC1073
if [ -n  "$SERVER_PORT" ]; then
    PARAMS="$PARAMS --server.port=$SERVER_PORT "
fi
if [ -n  "$SPRING_PROFILES_ACTIVE" ]; then
    PARAMS="$PARAMS --spring.profiles.active=$SPRING_PROFILES_ACTIVE "
fi
if [ -n  "$NACOS_ADDR" ]; then
    PARAMS="$PARAMS --spring.cloud.nacos.server-addr=$NACOS_ADDR"
fi
if [ -n "$OTHER_PARAMS" ];  then
    PARAMS="$PARAMS $OTHER_PARAMS"
fi
# Then run the main container command.
exec  java $JAVA_OPTS -jar  app.jar $PARAMS
docker-compose up demo 

Error creating bean with name 'projectController': Unsatisfied dependency expressed through field 'service';

copy iconCopydownload iconDownload
 @Mapper
 public interface ProjectMapper extends BaseMapper<Project> {

 }
@SpringBootApplication(exclude = {ShiroAnnotationProcessorAutoConfiguration.class, 
ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan(basePackage="cn.my.pm.project.mapper.*")
public class ProjectApplication {

public static void main(String[] args) {
    SpringApplication.run(ProjectApplication.class, args);
}
-----------------------
 @Mapper
 public interface ProjectMapper extends BaseMapper<Project> {

 }
@SpringBootApplication(exclude = {ShiroAnnotationProcessorAutoConfiguration.class, 
ShiroAutoConfiguration.class, ShiroBeanAutoConfiguration.class})
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan(basePackage="cn.my.pm.project.mapper.*")
public class ProjectApplication {

public static void main(String[] args) {
    SpringApplication.run(ProjectApplication.class, args);
}
-----------------------
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan(value={"org.abc.modules.**.mapper*", "cn.my.pm.**.mapper*"})
public class MybatisPlusConfig {
……
}

Community Discussions

Trending Discussions on nacos
  • How to extract kubernetes pod command execution result attributes
  • How can i change heap size when i use docker-compose and dockerfile to create a javaproject?
  • Error creating bean with name 'projectController': Unsatisfied dependency expressed through field 'service';
  • How to find which pom item introduces a specific external dependency?
Trending Discussions on nacos

QUESTION

How to extract kubernetes pod command execution result attributes

Asked 2022-Mar-03 at 16:00

I am connecting to pod via client-Go and I want to get the properties of the file directory

func GetPodFiles(c *gin.Context)  {
    client, _ := Init.ClusterID(c)
    path := c.DefaultQuery("path", "/")
    cmd := []string{
        "sh",
        "-c",
        fmt.Sprintf("ls -l %s", path),
    }
    config, _ := Init.ClusterCfg(c)
    req := client.CoreV1().RESTClient().Post().
        Resource("pods").
        Name("nacos-0").
        Namespace("default").SubResource("exec").Param("container", "nacos")
    req.VersionedParams(
        &v1.PodExecOptions{
            Command: cmd,
            Stdin:   false,
            Stdout:  true,
            Stderr:  true,
            TTY:     false,
        },
        scheme.ParameterCodec,
    )

    var stdout, stderr bytes.Buffer
    exec, err := remotecommand.NewSPDYExecutor(config, "POST", req.URL())
    if err != nil {
        response.FailWithMessage(response.InternalServerError, err.Error(), c)
        return
    }
    err = exec.Stream(remotecommand.StreamOptions{
        Stdin:  nil,
        Stdout: &stdout,
        Stderr: &stderr,
    })
    if err != nil {
        response.FailWithMessage(response.InternalServerError, "Error obtaining file", c)
        return
    }

    fmt.Println(stdout.String())
}

Execution Result Output

total 0
lrwxrwxrwx   1 root root   7 Jun  1  2018 bin -> usr/bin
drwxr-xr-x   5 root root 360 Feb 16 16:39 dev
lrwxrwxrwx   1 root root   8 Jun  1  2018 sbin -> usr/sbin
drwxr-xr-x   2 root root   6 Apr 11  2018 srv

Expect the result

"data": [
        {
            "perm": "drwxr-xr-x",
            "mod_time": "2022-03-02 15:02:15",
            "kind": "d",
            "name": "temp",
            "size": ""
        },
]

Is there a good way or a golang third-party library to handle it. Please let me know. Thank you

ANSWER

Answered 2022-Mar-03 at 16:00

In a Kubernetes pod you can execute the stat linux command instead of ls command.

$ stat yourFileOrDirName

The output of this command by default is like this:

  File: yourFileOrDirName
  Size: 346             Blocks: 0          IO Block: 4096   directory
Device: 51h/82d Inode: 40431       Links: 1
Access: (0755/drwxr-xr-x)  Uid: ( 1000/ username)   Gid: ( 1000/ groupname)
Access: 2022-03-02 11:59:07.384821351 +0100
Modify: 2022-03-02 11:58:48.733821177 +0100
Change: 2022-03-02 11:58:48.733821177 +0100
 Birth: 2021-12-21 11:12:05.571841723 +0100

But you can tweak its output like this:

$ stat --printf="%n,%A,%y,%s" yourFileOrDirName

where %n - file name, %A - permission bits and file type in human readable form, %y - time of last data modification human-readable, %s - total size, in bytes. You can also choose any character as a delimiter instead of comma.

the output will be:

yourFileOrDirName,drwxr-xr-x,2022-03-02 11:58:48.733821177 +0100,346

See more info about the stat command here.

After you get such output, I believe you can easily 'convert' it to json format if you really need it.

Furthermore, you can run the stat command like this:

$ stat --printf="{\"data\":[{\"name\":\"%n\",\"perm\":\"%A\",\"mod_time\":\"%y\",\"size\":\"%s\"}]}" yourFileOrDirName

Or as @mdaniel suggested, since the command does not contain any shell variables, nor a ', the cleaner command is:

stat --printf='{"data":[{"name":"%n","perm":"%A","mod_time":"%y","size":"%s"}]}' yourFileOrDirName

and get the DIY json output:

{"data":[{"name":"yourFileOrDirName","perm":"drwxrwxr-x","mod_time":"2022-02-04 15:17:27.000000000 +0000","size":"4096"}]}

Source https://stackoverflow.com/questions/71331142

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install nacos

It is super easy to get started with your first project.
Quick start with Nacos command and console
Quick start with dubbo
Quick start with spring cloud
Quick start with kubernetes
Github Release
Baidu Netdisk Fetch Code : rest

Support

You can view the full documentation from the Nacos website. All the latest and long-term notice can also be found here from Github notice issue.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with nacos
Consider Popular Microservice Libraries
Compare Microservice Libraries with Highest Support
Compare Microservice Libraries with Highest Security
Compare Microservice Libraries with Permissive License
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.