Add CLI command to view system status; release v0.12.2 by whummer · Pull Request #3224 · localstack/localstack · GitHub
Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ In addition to the above, the [**Pro version** of LocalStack](https://localstack
* **IoT**
* **Kinesis Data Analytics**
* **Lambda Layers**
* **Managed Streaming for Kafka (MSK)**
* **MediaStore**
* **QLDB**
* **RDS**
Expand Down
3 changes: 3 additions & 0 deletions bin/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,6 @@ RUN rm -rf localstack/infra/elasticsearch/jdk/
RUN rm -rf /root/.npm; \
apk del --purge autoconf automake boost-dev build-base g++ gcc giflib krb5-conf krb5-libs libc-dev \
libffi-dev libjpeg-turbo libmagic libpng linux-headers musl-dev openssl-dev python3-dev

# final fixes
RUN which python || ln -s /usr/bin/python3 /usr/bin/python
2 changes: 1 addition & 1 deletion localstack/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import localstack_client.config

# LocalStack version
VERSION = '0.12.1'
VERSION = '0.12.2'

# constant to represent the "local" region, i.e., local machine
REGION_LOCAL = 'local'
Expand Down
52 changes: 48 additions & 4 deletions localstack/utils/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
import sys
import json
import time
import select
import pkgutil
Expand Down Expand Up @@ -139,7 +140,8 @@ def load_plugins(scope=None):
return PLUGINS_LOADED[scope]

t1 = now_utc()
setup_logging()
log_level = logging.WARNING if scope == PLUGIN_SCOPE_COMMANDS else None
setup_logging(log_level=log_level)

loaded_files = []
result = []
Expand Down Expand Up @@ -185,6 +187,25 @@ def docker_container_running(container_name):
return container_name in container_names


def get_docker_image_details(image_name=None):
image_name = image_name or get_docker_image_to_start()
try:
result = run('%s inspect %s' % (config.DOCKER_CMD, image_name), print_error=False)
result = json.loads(to_str(result))
assert len(result)
except Exception:
return {}
if len(result) > 1:
LOG.warning('Found multiple images (%s) named "%s"' % (len(result), image_name))
result = result[0]
result = {
'id': result['Id'].replace('sha256:', '')[:12],
'tag': (result.get('RepoTags') or ['latest'])[0].split(':')[-1],
'created': result['Created'].split('.')[0]
}
return result


def get_docker_container_names():
cmd = "%s ps --format '{{.Names}}'" % config.DOCKER_CMD
try:
Expand All @@ -205,15 +226,38 @@ def get_main_container_ip():

def get_main_container_name():
cmd = "%s inspect -f '{{ .Name }}' %s" % (config.DOCKER_CMD, config.HOSTNAME)
return run(cmd).strip().lstrip('/')
try:
return run(cmd, print_error=False).strip().lstrip('/')
except Exception:
return config.MAIN_CONTAINER_NAME


def get_server_version():
docker_cmd = config.DOCKER_CMD
try:
# try to extract from existing running container
container_name = get_main_container_name()
version = run('%s exec -it %s bin/localstack --version' % (docker_cmd, container_name), print_error=False)
version = version.strip().split('\n')[-1]
return version
except Exception:
try:
# try to extract by starting a new container
img_name = get_docker_image_to_start()
version = run('%s run --entrypoint= -it %s bin/localstack --version' % (docker_cmd, img_name))
version = version.strip().split('\n')[-1]
return version
except Exception:
# fall back to default constant
return constants.VERSION


def setup_logging():
def setup_logging(log_level=None):
# determine and set log level
if PLUGINS_LOADED.get('_logging_'):
return
PLUGINS_LOADED['_logging_'] = True
log_level = logging.DEBUG if is_debug() else logging.INFO
log_level = log_level or (logging.DEBUG if is_debug() else logging.INFO)
logging.basicConfig(level=log_level, format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT)

# set up werkzeug logger
Expand Down
30 changes: 28 additions & 2 deletions localstack/utils/cli.py