Honcho: a python clone of Foreman. For managing Procfile-based applications.

Overview
     ___           ___           ___           ___           ___           ___
    /\__\         /\  \         /\__\         /\  \         /\__\         /\  \
   /:/  /        /::\  \       /::|  |       /::\  \       /:/  /        /::\  \
  /:/__/        /:/\:\  \     /:|:|  |      /:/\:\  \     /:/__/        /:/\:\  \
 /::\  \ ___   /:/  \:\  \   /:/|:|  |__   /:/  \:\  \   /::\  \ ___   /:/  \:\  \
/:/\:\  /\__\ /:/__/ \:\__\ /:/ |:| /\__\ /:/__/ \:\__\ /:/\:\  /\__\ /:/__/ \:\__\
\/__\:\/:/  / \:\  \ /:/  / \/__|:|/:/  / \:\  \  \/__/ \/__\:\/:/  / \:\  \ /:/  /
     \::/  /   \:\  /:/  /      |:/:/  /   \:\  \            \::/  /   \:\  /:/  /
     /:/  /     \:\/:/  /       |::/  /     \:\  \           /:/  /     \:\/:/  /
    /:/  /       \::/  /        /:/  /       \:\__\         /:/  /       \::/  /
    \/__/         \/__/         \/__/         \/__/         \/__/         \/__/

Latest Version on PyPI Build Status

Honcho is a Python port of Foreman, a tool for managing Procfile-based applications.

Why a port?

Installing Honcho

pip install honcho

How to use Honcho

The 30-second version:

  1. Write a Procfile:

    $ cat >Procfile <<EOM
    web: python serve.py
    redis: redis-server
    EOM
    
  2. Optional: write a .env file to configure your app:

    $ cat >.env <<EOM
    PORT=6000
    REDIS_URI=redis://localhost:6789/0
    EOM
    
  3. Run the app with Honcho:

    $ honcho start
    

For more detail and an explanation of the circumstances in which Honcho might be useful, consult the Honcho documentation.

License

Honcho is released under the terms of the MIT license, a copy of which can be found in LICENSE.

Comments
  • pdb experience is sub-par

    pdb experience is sub-par

    If I set PYTHONUNBUFFERED I can kind of use pdb, but it's less than ideal because the (Pdb) prompt isn't displayed until after I enter a command, and all output is prefixed with the timestamp/process indicator.

    opened by chadwhitacre 21
  • Export: Add custom template support

    Export: Add custom template support

    This adds the ability to use a custom template when exporting to supervisord.

    Fixes: GH-88

    Example:
    $ honcho export supervisord . -t my_supervisord_template.conf.jinja2
    
    $ cat export_test.conf
    # *****************************************************
    # This is a custom supervisord template for honcho
    # blah blah blah
    # *****************************************************
    
    [program:export_test-ansvc]
    MONKEY=YES
    command=/bin/sh -c 'bin/ansvc start'
    autostart=true
    autorestart=true
    stopsignal=QUIT
    stdout_logfile=/var/log/export_test/ansvc-0.log
    stderr_logfile=/var/log/export_test/ansvc-0.error.log
    user=marca
    directory=/Users/marca/dev/git-repos/honcho/export_test
    environment=PORT="5000"
    
    [group:export_test]
    programs=export_test-ansvc
    
    opened by msabramo 20
  • Implement `honcho run PROCESS`

    Implement `honcho run PROCESS`

    This makes honcho run primarily about running a Procfile-specified process in the foreground (the first proposal at https://github.com/nickstenning/honcho/issues/56#issuecomment-34546939). Previously it was about running an arbitrary shell command, which still works, but now as the fall-through case if a single arg to honcho run doesn't match a Procfile process.

    The reason this change is desirable is to be able to use debugging tools such as pdb along with Procfile process aliases (#56). Furthermore, this brings Honcho back into harmony with Foreman's behavior, but in a way that is documented more sensibly (Foreman presents the process case as the exception rather than the command case).

    This change is backwards-compatible except for edge cases where a shell command name was used as a Procfile process name. So, for example, if mv was a process name, then calling honcho run mv would now invoke the Procfile process rather than the shell command. Since we also check for the number of arguments when trying to interpret as a process name, this edge case is especially edgy. I think this can safely be considered a backwards-compatible change for all practical purposes.


    P.S. For Gittip folks: I'm introducing this fork on Gittip in https://github.com/gittip/www.gittip.com/pull/2384. If/when you change it here's how to revendor it:

    • Go into a local working copy of the fork.
    • echo __version__ = "'$(git rev-parse --short=8 HEAD)'" > honcho/__init__.py
    • python setup.py sdist
    • mv dist/honcho-*.tar.gz ../www.gittip.com/vendor/

    Then go back over to www.gittip.com, remove the old version and update requirements.txt.

    opened by chadwhitacre 16
  • Catch SIGTERM and terminate process groups

    Catch SIGTERM and terminate process groups

    This is to fix a problem that when supervisord terminated honcho, the child processes kept running.

    • Catch SIGTERM so we know when honcho is being terminated, and run terminate().
    • In terminate(), signal the entire process group, not just the shell process that was used to start the process. Without this, the shell process exited but not its children.
    opened by poirier 15
  • Improve design and test coverage of export package

    Improve design and test coverage of export package

    This PR:

    • Moves responsibility for I/O back into honcho.command rather than honcho.export.
    • Changes exporters so that #export() takes a list of honcho.environ.ProcessParams objects and optional template context. This means that concurrency, process naming, and port assignment is now much more likely to be consistent between honcho start and honcho export.
    • Improves test coverage of the honcho.export package.
    • Removes a couple more fragile export integration tests.
    opened by nickstenning 13
  • Win support

    Win support

    Here is a working version of support for Windows for #28 All tests are passing. Most of the adjustments were on the quirks of MSFT of course, such as command line arguments quoting, no support for Signals, adjusting tests expectations in particular line endings. This is working acceptably enough in that state, though it may not be bullet proof as it is as there are too many process handling quirks in Windows compared to POSIX.

    That said, this could be a great addition for now. I could then work out integrating something like mozprocess that provides enhanced handling of Windows processes and should make the Windows side more solid.

    (honcho) c:\w421\honcho>nosetests
    ............................
    ----------------------------------------------------------------------
    Ran 28 tests in 18.568s
    
    OK
    
    opened by pombredanne 12
  • Export add integration test

    Export add integration test

    This PR:

    • Adds integration tests for the export functionality (4b33c2c)
    • Tweaks a few things so that tests pass consistently. E.g.:
      • Sort dictionary keys to get consistent ordering from run to run (e32be90)
      • Use items in place of iteritems in upstart template for Python 3 compatibility (3e9c2d9)
      • Apply fix from https://github.com/nickstenning/honcho/pull/102 so that we don't get spurious test failures that confuse things. (5148677)
    $ tox -e py26,py27,py32,py33,py34,lint
    ...
      py26: commands succeeded
      py27: commands succeeded
      py32: commands succeeded
      py33: commands succeeded
      py34: commands succeeded
      lint: commands succeeded
      congratulations :)
    
    opened by msabramo 10
  • Crash when printing to console with special characters.

    Crash when printing to console with special characters.

    I'm experiencing crashes when Honcho tries to print to console with special characters:

    Traceback (most recent call last):
    File "/app/.heroku/python/bin/honcho", line 9, in <module>
        load_entry_point('honcho==0.4.2', 'console_scripts', 'honcho')()
    File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 292, in main
        app.parse()
    File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 129, in parse
        options.func(self, options)
    File "/app/.heroku/python/lib/python2.7/site-packages/honcho/command.py", line 190, in start
        sys.exit(process_manager.loop())
    File "/app/.heroku/python/lib/python2.7/site-packages/honcho/process.py", line 114, in loop
    File "/app/.heroku/python/lib/python2.7/site-packages/honcho/printer.py", line 22, in write
    

    Here is a Stackoverflow question with more details:

    http://stackoverflow.com/questions/19100116/looks-like-logs-are-crashing-my-django-app

    opened by TimotheeJeannin 10
  • Allow run to run commands in Procfile like foreman

    Allow run to run commands in Procfile like foreman

    currently in foreman if you run $ foreman run PROCNAME it will run from the procfile if it's available, and the exit code of the command will equal the exit code of the subprocess. This diff honors that change.

    opened by axiak 10
  • Fix stop/ start issue #131

    Fix stop/ start issue #131

    This approach stops child processing hanging with exported upstart process by leveraging setuid (http://upstart.ubuntu.com/cookbook/#setuid). service {app} restart now works correctly for me.

    opened by gamb 9
  • Add support for -t/--template option to export

    Add support for -t/--template option to export

    This is a honcho analogue of the corresponding options to foreman export -- See:

    • http://ddollar.github.io/foreman/#EXPORTING
    • https://github.com/ddollar/foreman/pull/46

    This lets you specify a custom Jinja template to be used when exporting to a supervisord config file.

    Fixes: GH-88

    See: https://github.com/nickstenning/honcho/issues/88

    OK, I just updated this so that --template is a directory. I'm not quite sure how to test this in an automated way, but I did do manual testing.

    [[email protected] export_test]$ ls -l upstart_template.d
    total 24
    -rw-r--r--+ 1 marca  staff  353 Feb 23 06:01 master.conf
    -rw-r--r--+ 1 marca  staff  380 Feb 23 06:02 process.conf
    -rw-r--r--+ 1 marca  staff  119 Feb 23 06:02 process_master.conf
    
    [[email protected] export_test]$ honcho export upstart upstart-export --template upstart_template.d
    2015-02-23 07:59:43 [20837] [INFO] Writing 'upstart-export/export_test.conf'
    2015-02-23 07:59:43 [20837] [INFO] Writing 'upstart-export/export_test-ansvc.conf'
    2015-02-23 07:59:43 [20837] [INFO] Writing 'upstart-export/export_test-ansvc-1.conf'
    
    [[email protected] export_test]$ honcho export upstart upstart-export
    2015-02-23 08:00:16 [20841] [INFO] Writing 'upstart-export/export_test.conf'
    2015-02-23 08:00:16 [20841] [INFO] Writing 'upstart-export/export_test-ansvc.conf'
    2015-02-23 08:00:16 [20841] [INFO] Writing 'upstart-export/export_test-ansvc-1.conf'
    
    [[email protected] export_test]$ ls -l supervisor-template.d
    total 8
    -rw-r--r--+ 1 marca  staff  776 Dec 23 08:09 supervisord.conf
    
    [[email protected] export_test]$ honcho export supervisord out --template=supervisor-template.d
    2015-02-23 08:00:39 [20847] [INFO] Writing 'out/export_test.conf'
    
    [[email protected] export_test]$ honcho export supervisord out
    2015-02-23 08:01:05 [20855] [INFO] Writing 'out/export_test.conf'
    
    opened by msabramo 9
  • Handle deprecation of pkg_resources and favor importlib

    Handle deprecation of pkg_resources and favor importlib

    Specifically, the Python 3.10 images on CircleCI no longer include pkg_resrouces as it's deprecated:

    $ honcho start
    Traceback (most recent call last):
      File "/home/circleci/myproject/.venv/bin/honcho", line 5, in <module>
        from honcho.command import main
      File "/home/circleci/myproject/.venv/lib/python3.10/site-packages/honcho/command.py", line 10, in <module>
        from pkg_resources import iter_entry_points
    ModuleNotFoundError: No module named 'pkg_resources'
    

    Starting in Python 3.8, importlib.metdata is the preferred way to find entry points.

    opened by jacebrowning 0
  • Prevent existing environment variables from being overriden?

    Prevent existing environment variables from being overriden?

    Hey @nickstenning thanks for this project!

    I was wondering if there's a way to prevent a .env file from overwriting an existing env var. Consider the following example:

    $ cat .env
    FOO="using FOO from .env"
    
    $ FOO="Using FOO from shell" honcho run -e .env env | grep FOO
    FOO=Using .env.local
    

    Ideally, if FOO is already set, I don't think a .env file should overwrite it, like if the environment variable gets set at runtime in a docker-compose.yml, k8s, or whatever orchestrator may be setting them.

    Similarly this would be helpful when passing multiple .env files for different environments for example:

    ❯ honcho run -e .env.local,.env.dev,.env env | grep FOO
    FOO=Using .env
    

    It seems that right now the last file parsed will always take over an environment variable previously set, but it would be nice if it didn't override them.

    opened by evandam 0
  • systemd exporter not working

    systemd exporter not working

    Just leaving myself a note here that the systemd exporter seems broken. The process group targets don't correctly specify that they Want the service files.

    Also probably worth fixing StandardOutput=syslog (use StandardOutput=journal instead) and pick the right KillMode (as process is unlikely to be the correct choice.

    opened by nickstenning 0
  • printer: Make time_format optional

    printer: Make time_format optional

    Also fixes #220.

    Any falsey value for time_format passed to the printer disables it entirely. It could have been done before, but it ends up prefixing with an extra space.

    opened by mattrobenolt 1
Releases(v1.1.0)
  • v1.1.0(Oct 30, 2021)

    • ADDED: Honcho can now export to a set of systemd unit files. Thanks to Matt Melquiond for contributing the systemd exporter.
    • ADDED: python -m honcho now works identically to honcho.
    • CHANGED: Dash (-) is now an allowed character in process types (thanks to Ben Spaulding).
    • CHANGED: Honcho no longer opens a new console for every process on Windows. Thank you to Benedikt Arnold for contributing the fix.
    • CHANGED: Python versions 3.6 through 3.10 are now supported environments.
    • CHANGED: Python 3.4 and 3.5 are no longer supported environments.
    • FIXED: --no-colour and --no-prefix now work whether specified before or after the command.
    • FIXED: Honcho on Python 3.8 will no longer issue a RuntimeWarning about line buffering not being supported in binary mode.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Apr 1, 2017)

  • v1.0.0(Apr 1, 2017)

    • ADDED: Automatically suppress colouring when the STDOUT is not a TTY.
    • ADDED: Honcho now exposes a HONCHO_PROCESS_NAME environment variable to its child processes which contains the name of the process (e.g. web.1, worker.2, etc.)
    • ADDED: All subcommands now support --no-colour and --no-prefix options to suppress ANSI coloured output and the logging prefix, respectively.
    • CHANGED: The Upstart configuration generated by the Upstart exporter no longer creates a log directory to which to send process output, in favour of relying on Upstart's built-in job logging support (present since at least Upstart 1.4).
    Source code(tar.gz)
    Source code(zip)
  • v0.7.1(Apr 1, 2017)

    • FIXED: Honcho now correctly pays attention to the -f argument when provided before a command, fixing a regression introduced in the previous version. Thanks to Marc Krull for reporting and fixing.
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Apr 10, 2016)

    • ADDED: Honcho can now export to a runit service directory.
    • ADDED: You can now specify the location of the Procfile with a PROCFILE environment variable.
    • ADDED: Python 3.5 is now a supported environment.
    • CHANGED: Python 3.0, 3.1, and 3.2 are no longer supported environments.
    • FIXED: The run command now correctly parses commands which include the -- "end of arguments" separator.
    • FIXED: Honcho no longer fails to load .env files if the Procfile is not in the application directory.
    • FIXED: ANSI colour codes from running programs can no longer interfere with Honcho's output.
    • FIXED: Export of environment variables containing special characters no longer breaks the Upstart exporter.
    • FIXED: The supervisord exporter now correctly escapes the % symbol in commands and environment variable values.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.6(Mar 16, 2015)

  • v0.6.5(Mar 9, 2015)

    • ADDED: Exporter templates can now be overridden by the --template-dir option to honcho export.
    • CHANGED: Colour output is now supported by default on Windows.
    • CHANGED: Base port is no longer required to be a multiple of 1000.
    • FIXED: Output is no longer buffered on Python 3.
    • FIXED: Environment variables in .env files can now take any POSIX-valid values rather than simple alphanumerics only.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.4(Mar 9, 2015)

  • v0.6.3(Mar 9, 2015)

  • v0.6.2(Mar 9, 2015)

    • ADDED: Colour output is now supported on Windows when the colorama package is installed.
    • FIXED: Honcho no longer always crashes on Windows. Sorry about that.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Mar 9, 2015)

  • v0.6.0(Mar 9, 2015)

    • ADDED: Started keeping a changelog!
    • ADDED: A version command: honcho version will print the current version.
    • CHANGED: Supervisor export now executes commands inside a shell (like other exporters and honcho itself).
    • CHANGED: Supervisor exports now sets PORT environment variable consistently with other exporters and the rest of honcho.
    • CHANGED: Supervisor export now takes a directory as the location parameter on the command line, e.g. honcho export supervisord /etc/supervisord.d, thus making the use consistent with other exporters. N.B. This is a backwards-incompatible change!
    • FIXED: Addressed numerous text encoding bugs.
    • FIXED: Honcho exporters can now be used on Python 3.2
    • FIXED: Honcho no longer crashes when all processes are made --quiet.
    Source code(tar.gz)
    Source code(zip)
A tool to clone efficiently all the repos in an organization

cloner A tool to clone efficiently all the repos in an organization Installation MacOS (not yet tested) python3 -m venv .venv pip3 install virtualenv

Ramon 6 Apr 15, 2022
Containerize a python web application

containerize a python web application introduction this document is part of GDSC at the university of bahrain you don't need to follow along, fell fre

abdullah mosibah 1 Oct 19, 2021
Cado Response Integration with Amazon GuardDuty using AWS Lambda

Cado Response Integration with Amazon GuardDuty using AWS Lambda This repository contains a simple example where: An alert is triggered by GuardDuty T

Cado Security 4 Mar 02, 2022
Let's learn how to build, release and operate your containerized applications to Amazon ECS and AWS Fargate using AWS Copilot.

🚀 Welcome to AWS Copilot Workshop In this workshop, you'll learn how to build, release and operate your containerised applications to Amazon ECS and

Donnie Prakoso 15 Jul 14, 2022
MagTape is a Policy-as-Code tool for Kubernetes that allows for evaluating Kubernetes resources against a set of defined policies to inform and enforce best practice configurations.

MagTape is a Policy-as-Code tool for Kubernetes that allows for evaluating Kubernetes resources against a set of defined policies to inform and enforce best practice configurations. MagTape includes

T-Mobile 143 Dec 27, 2022
Kube kombu - Running kombu consumers with support of liveness probe for kubernetes

Setup and Running Kombu consumers Steps: Install python 3.9 or greater on your s

Anmol Porwal 5 Dec 10, 2022
🐳 Docker templates for various languages.

Docker Deployment Templates One Stop repository for Docker Compose and Docker Templates for Deployment. Features Python (FastAPI, Flask) Screenshots D

CodeChef-VIT 6 Aug 28, 2022
Some automation scripts to setup a deployable development database server (with docker).

Postgres-Docker Database Initializer This is a simple automation script that will create a Docker Postgres database with a custom username, password,

Pysogge 1 Nov 11, 2021
DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

Sehan Weerasekara 1 Feb 19, 2022
Oncall is a calendar tool designed for scheduling and managing on-call shifts. It can be used as source of dynamic ownership info for paging systems like http://iris.claims.

Oncall See admin docs for information on how to run and manage Oncall. Development setup Prerequisites Debian/Ubuntu - sudo apt-get install libsasl2-d

LinkedIn 928 Dec 22, 2022
Travis CI testing a Dockerfile based on Palantir's remix of Apache Cassandra, testing IaC, and testing integration health of Debian

Testing Palantir's remix of Apache Cassandra with Snyk & Travis CI This repository is to show Travis CI testing a Dockerfile based on Palantir's remix

Montana Mendy 1 Dec 20, 2021
A system for managing CI data for Mozilla projects

Treeherder Description Treeherder is a reporting dashboard for Mozilla checkins. It allows users to see the results of automatic builds and their resp

Mozilla 235 Dec 22, 2022
Phonebook application to manage phone numbers

PhoneBook Phonebook application to manage phone numbers. How to Use run main.py python file. python3 main.py Links Download Source Code: Click Here M

Mohammad Dori 3 Jul 15, 2022
docker-compose工程部署时的辅助脚本

okta-cmd Introduction docker-compose 辅助脚本

完美风暴666 4 Dec 09, 2021
Deploying a production-ready Django project using Nginx and Gunicorn

django-nginx-gunicorn This project is for deploying a production-ready Django project using Nginx and Gunicorn. Running a local server of Django is no

Arash Sayareh 8 Jul 03, 2022
Wubes is like Qubes but for Windows.

Qubes containerization on Windows. The idea is to leverage the Windows Sandbox technology to spawn applications in isolation.

NCC Group Plc 124 Dec 16, 2022
Hatch plugin for Docker containers

hatch-containers CI/CD Package Meta This provides a plugin for Hatch that allows

Ofek Lev 11 Dec 30, 2022
Dockerized service to backup all running database containers

Docker Database Backup Dockerized service to automatically backup all of your database containers. Docker Image Tags: docker.io/jandi/database-backup

Jan Dittrich 16 Dec 31, 2022
Manage your azure VM easily!

Azure-manager Manage your VM in Azure using cookies.

Team 1injex 129 Dec 17, 2022
Webinar oficial Zabbix Brasil. Uma série de 4 aulas sobre API do Zabbix.

Repositório de scripts do Webinar de API do Zabbix Webinar oficial Zabbix Brasil. Uma série de 4 aulas sobre API do Zabbix. Nossos encontros [x] 04/11

Robert Silva 7 Mar 31, 2022