Skip to content

netgroup/meco-devel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meco

MEga COnstellation emulator

Meco is a gRPC-based application that simulates and manages a Low Earth Orbit (LEO) Mega Constellation. It provides a command-line interface (CLI) to:

  • Start a background gRPC server (on)
  • Stop the server (off)
  • Send a resource descriptor file to the server (start)

Features

  • Manage a gRPC server via CLI
  • Supports daemonized execution
  • Implements structured logging using Python's logging module
  • Supports auto-completion with argcomplete
  • Uses gRPC for communication

Installation

Install Dependencies

pip install argcomplete grpcio grpcio-tools

Enable CLI Auto-Completion

For Bash users:

eval "$(register-python-argcomplete meco)"

For global auto-completion (one-time setup):

activate-global-python-argcomplete

Compile gRPC Protocol Buffers

Ensure you have the meco.proto file and run:

python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. meco.proto

Usage

Start the gRPC Server (Daemon Mode)

python meco.py on

Runs the server in the background and stores its PID in /tmp/meco_server.pid.

Stop the gRPC Server

python meco.py off

Stops the server by terminating the background process.

Send a Resource Descriptor File

python meco.py start config.json

Sends config.json to the gRPC server for processing.

Show Help Menu

python meco.py --help

Example Commands

Start the Server

python meco.py on

Output:

2025-02-07 12:00:00 [INFO] Meco server turned ON in background (PID: 12345).

Stop the Server

python meco.py off

Output:

2025-02-07 12:05:00 [INFO] Turning OFF Meco server (PID: 12345)...
2025-02-07 12:05:01 [INFO] Meco server turned OFF.

Send a Resource File

python meco.py start my_config.json

If the file exists:

2025-02-07 12:10:00 [INFO] Successfully started with resource file: my_config.json

If the file is missing:

2025-02-07 12:10:05 [ERROR] Error: File 'my_config.json' does not exist.

Check Available Commands

python meco.py --help

Output:

usage: meco [-h] {on,off,start} ...

Emulates a LEO Mega Constellation

positional arguments:
  {on,off,start}  Available commands
    on            Turn the Meco gRPC server ON (daemon mode)
    off           Turn the Meco gRPC server OFF
    start         Send a resource descriptor file to the Meco server

optional arguments:
  -h, --help      show this help message and exit

Logging

Meco uses Python's logging module for structured logs.

Log levels used:

  • INFO → General information (logger.info())
  • WARNING → Server status (logger.warning())
  • ERROR → Issues (logger.error())

Example Logs

2025-02-07 12:00:00 [INFO] Meco server started on port 50051.
2025-02-07 12:05:30 [INFO] Start() called with resource descriptor file: config.json
2025-02-07 12:06:10 [ERROR] Error: File 'config.json' does not exist.

Development Setup

1. Clone the Repository

git clone https://github.com/your-repo/meco.git
cd meco

2. Set Up a Python Virtual Environment

It is recommended to use a virtual environment to isolate dependencies.

Create and Activate the Virtual Environment:

For Linux/macOS:

python3 -m venv venv
source venv/bin/activate

For Windows:

python -m venv venv
venv\Scripts\activate

Install Dependencies:

pip install -r requirements.txt

Verify Installation:

python -m grpc_tools.protoc --version

3. Compile gRPC Stubs

python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. meco.proto

4. Run the Server in Debug Mode

python meco.py on

5. Run the Client for Testing

python meco.py start test.json

6. Deactivate the Virtual Environment (When Done)

deactivate

Troubleshooting

"server already running" message when running python meco.py on

Check if the PID file exists:

cat /tmp/meco_server.pid

Manually stop the process:

kill -9 $(cat /tmp/meco_server.pid)
rm /tmp/meco_server.pid

"File does not exist" error when running python meco.py start file.json

Ensure the file exists:

ls -lh file.json

Command completion is not working

Re-enable argcomplete:

eval "$(register-python-argcomplete meco)"

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Future Improvements

  • Add Docker support for containerized deployment
  • Add unit tests for CLI and gRPC services

Contributors

  • Stefano Salsano - Maintainer

About

MEga COnstellation emulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 90.8%
  • Shell 9.2%