Meaning of option `fabric-ca-server -d`? - hyperledger-fabric

The fabric-samples test network setup for fabric-ca-server (found in fabric-samples/test-network/docker/docker-compose-ca.yaml) initializes the certificate server with
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
The option -b is clear in meaning - as shown in the output from --help and the online copy of that, it's a user/password for bootstrapping the config file. The -d flag, however, is completely undocumented. What does it do?

This is the flag to enable debug mode; see Deploy Guide, Start the TLS CA server:
Optional flags:
-d - If you want to run the server in DEBUG mode which facilitates problem diagnosis, you can include the -d flag on the start command. However, in general it is not recommended to run a server with debug enabled as this will cause the server to perform slower.
-p - If you want the server to run on a port different than what is specified in the configuration .yaml file, you can override the existing port.
The option is defined here as a tag, and parsed here. For unknown reasons, it is set to be hidden from fabric-ca-server --help.
(h/t #david_k)

Related

Is there a command similar to docker exec in lando?

We are using our develpment environment in a lando and non lando context alike. Is there a way to trigger a shell script from outside lando similar to docker exec ?
lando exec does not work obvisously and it is also not part of the standard commands, but maybe tehre is a way to create it or add it as a plugin?
It turned out, that lando has this build in as part of the tooling api. It does not allow a "freestyle" command, but you can predefine any usefull shortcut you like in the .lando.yml.
A simple example in our case:
name: my_project
recipe: drupal9
config:
database: mariadb
drush: ^10
php: '7.4'
webroot: ./web
tooling:
cex:
service: appserver
description: Export the drupal config
cmd: './scripts/cex.sh'
cim:
service: appserver
description: Install dependencies and import the latest config.
cmd: './scripts/cim.sh'
If you need root permissions, just add user: root
In the example above, you can simply call
lando cex or lando cim, to trigger the custom commands.
There is actually a better way to execute one time commands than using the tooling API, that is also more similar to docker exec:
# Opens an interactive terminal inside container
lando ssh
# Runs a specified command inside container
lando ssh -c "ls -la /"
You can change the target service/container and the executing user which runs the command:
--command, -c Run a command in the service
--service, -s SSH into this service [default: "appserver"]
--user, -u Run as a specific user
See full documentation for lando ssh here:
https://docs.lando.dev/basics/ssh.html#usage

How to debug docker restart not restarting in node.js app?

I have a container with a docker-compose like this
services:
app:
build:
context: app
restart: always
version: '3.5'
It launches a node app docker-compose run -d --name my-app app node myapp.js
the app is made to either run to completion or throw, and then the goal would be to have docker restart it in an infinite loop, regardless of the exit code. I'm unsure why but it doesn't restart it.
How can I debug this? I have no clue what exit code node is sending, nor do I know which exit code docker uses to decide to restart or not.
I am also on mac, haven't tested on linux yet. Edit: It does restart on linux, don't have another mac to see if the behavior is isolated to my mac only.
It is important to understand the following two concepts:
Ending your Node app doesn't mean the end of your container. Your container runs a shared process from your OS and your Node app is only a sub process of that. (Assuming your application runs with the Deamon)
The restart indicates the "starting" policy - it will never terminate and start your container again.
Having said that, what you need is a way you can really restart your container from within the application. The best way to do this is via Docker healthchecks:
https://docs.docker.com/engine/reference/builder/#healthcheck
Or, here are some answers on restarting a container from within the application.
Stopping docker container from inside
From Github Issue seems like it does not respect `--restart``, or from the #Charlie comment seems like its vary from platform to platform.
The docker-compose run command is for running “one-off” or “adhoc” tasks.The run command acts like docker run -ti in that it opens an interactive terminal to the container and returns an exit status matching the exit status of the process in the container.
docker-compose run
Also if its like docker run -it then I am not seeing an option for restart=always but it should then respect ``restart` option in compose.
Usage:
run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...]
SERVICE [COMMAND] [ARGS...]
Options:
-d, --detach Detached mode: Run container in the background, print
new container name.
--name NAME Assign a name to the container
--entrypoint CMD Override the entrypoint of the image.
-e KEY=VAL Set an environment variable (can be used multiple times)
-l, --label KEY=VAL Add or override a label (can be used multiple times)
-u, --user="" Run as specified username or uid
--no-deps Don't start linked services.
--rm Remove container after run. Ignored in detached mode.
-p, --publish=[] Publish a container's port(s) to the host
--service-ports Run command with the service's ports enabled and mapped
to the host.
--use-aliases Use the service's network aliases in the network(s) the
container connects to.
-v, --volume=[] Bind mount a volume (default [])
-T Disable pseudo-tty allocation. By default `docker-compose run`
allocates a TTY.
-w, --workdir="" Working directory inside the container

How can I run a flask app from outside the top level directory?

I am working through Miguel Grinberg's Flask Megatutorial (a microblog app), using an Amazon EC2 ubuntu microinstance.
Currently every time I want to start up the flask app I have to cd to the top-level directory ~/microblog/.
Then, I type: flask run -h 0.0.0.0 -p 50000 to start the application.
Is there a way to specify the directory in the commandline so I don't have to keep going to the directory to run the program? There doesn't seem to be but maybe I'm missing something. I'm also pretty new to linux.
~/microblog$ flask run --help
* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
Usage: flask run [OPTIONS]
Run a local development server.
This server is for development purposes only. It does not provide the
stability, security, or performance of production WSGI servers.
The reloader and debugger are enabled by default if FLASK_ENV=development
or FLASK_DEBUG=1.
Options:
-h, --host TEXT The interface to bind to.
-p, --port INTEGER The port to bind to.
--cert PATH Specify a certificate file to use HTTPS.
--key FILE The key file to use when specifying a
certificate.
--reload / --no-reload Enable or disable the reloader. By default
the reloader is active if debug is enabled.
--debugger / --no-debugger Enable or disable the debugger. By default
the debugger is active if debug is enabled.
--eager-loading / --lazy-loader
Enable or disable eager loading. By default
eager loading is enabled if the reloader is
disabled.
--with-threads / --without-threads
Enable or disable multithreading.
--extra-files PATH Extra files that trigger a reload on change.
Multiple paths are separated by ':'.
--help Show this message and exit.
you can do
export FLASK_APP=<your_directory>
and then run the command, also if you want to export the variable and to be persistent add it to the end of your ~/.bash_profile file with nano, vi or your favorite editor

What is the right way to cleanly shutdown fabric ca server?

To start a fabric ca server we use fabric-ca-server start -b admin:adminpw
What command or steps need to be followed to shut it down cleanly.
I have read and checked there is no default commands. Refer - https://jira.hyperledger.org/browse/FAB-1963?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aworklog-tabpanel
This is not currently possible, but see and comment on https://jira.hyperledger.org/browse/FAB-4487 to follow the status of adding this support.

docker-compose run -e KEY=VALUE not working using nodejs and protractor

Similar to docker run -e not working, bug?; except my docker command has its file in the correct order and I'd like to do it all in the command-line:
CLI
docker-compose up -d selenium
docker-compose port selenium 5900
docker-compose port selenium 4444
docker-compose build desktop
docker-compose run -e TAGS=test desktop
WARNING: The TAGS variable is not set. Defaulting to a blank string.
Starting MYTESTSUTIE ... done
Docker-compose.yml
desktop:
build: .
command: echo ${TAGS}
Docker-compose v1.16.1
Node.js v8.7
I have also tried with quotes, with brackets and attempting to escape characters, but nothing works.
Any help would be greatly appreciated.
EDIT: Before anybody suggests, I did find a way to do this by setting TAGS in advance using export TAGS="XX"; but I'd rather not still be reliant on a second command line if I don't have to be.
EDIT 2: I have tried updating to 1.18 and am running the script from either a Git Bash terminal or a Docker Quickstart Terminal as I am using a Windows 7 machine as a base-machine; but still no luck.
Okay, so after some communication with #MazelTov, it appears I can't do that. Unbeknown to me, even though I am already in a docker container to begin with, the command:
docker run -e
actually creates a new sub-container that gets the -e flag passed to it. This means that the YAML file that I want to pick up the variable can't do so as it's sitting in the host container.
Guess I'll have to use an export command to have it do what I want it to.

Resources