Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find out the possible environment variables for Hyperledger Fabric peer command?

When configuring a peer node to run, there are a number of environment variables included in the sample docker-compose files. Is there somewhere that I can find them all documented?

e.g.

environment:
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_PEER_ID=peer0.org1.example.com
  - CORE_LOGGING_PEER=debug
  - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
  - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
like image 970
christo4ferris Avatar asked Aug 01 '17 16:08

christo4ferris


3 Answers

Hyperledger Fabric provides a configuration file called core.yaml, you can find that inside the peer container on folder /etc/hyperledger/fabric/

Fabric uses Viper as configuration framework, which provides an ability to override values of configuration files by environmental variables. Basically it initialized as following:

// used to prefix config keys to prevent possible collisions
viper.SetEnvPrefix("core") 

// enforces to check values configured via environmental variables first
viper.AutomaticEnv()

This makes viper to seek for all configuration key among environmental variables prefixed by CORE string.

Now if for example we take a look on peer section (updated) within sample config:

peer:            
    id: jdoe            
    networkId: dev    
    listenAddress: 0.0.0.0:7051    
    address: 0.0.0.0:7051

any of these value could be overridden by exporting proper environmental variable, for instance peer network id:

export CORE_PEER_NETWORKID=mypeerID

Same also works for other sections, for example if we would like to control logging level of different components:

logging:

    peer:       info
    cauthdsl:   warning
    gossip:     warning
    ledger:     info
    msp:        warning
    policies:   warning
    grpc: error

To make msp component to log debug level message we need to export following variable:

export PEER_LOGGING_MSP=debug

Please note that this will take effect only if exported prior to peer start.

like image 93
Artem Barger Avatar answered Oct 17 '22 06:10

Artem Barger


Hyperledger Fabric provides a sample configuration file that basically includes all the possible properties for the peer component. Of course, you will need to convert the yaml properties to the corresponding environment variable name using the formula:

foo:

    bar: baz

becomes CORE_FOO_BAR=baz

The same applies to the orderer component, which has it's own sample configuration file.

like image 3
christo4ferris Avatar answered Oct 17 '22 06:10

christo4ferris


environment are actually items in core.yaml,replace "." with "_"

like image 1
Hao Wang Avatar answered Oct 17 '22 08:10

Hao Wang