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.

    [marca@marca-mac2 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
    
    [marca@marca-mac2 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'
    
    [marca@marca-mac2 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'
    
    [marca@marca-mac2 export_test]$ ls -l supervisor-template.d
    total 8
    -rw-r--r--+ 1 marca  staff  776 Dec 23 08:09 supervisord.conf
    
    [marca@marca-mac2 export_test]$ honcho export supervisord out --template=supervisor-template.d
    2015-02-23 08:00:39 [20847] [INFO] Writing 'out/export_test.conf'
    
    [marca@marca-mac2 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 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
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
More than 130 check plugins for Icinga and other Nagios-compatible monitoring applications. Each plugin is a standalone command line tool (written in Python) that provides a specific type of check.

Python-based Monitoring Check Plugins Collection This Enterprise Class Check Plugin Collection offers a package of more than 130 Python-based, Nagios-

Linuxfabrik 119 Dec 27, 2022
This repository contains code examples and documentation for learning how applications can be developed with Kubernetes

BigBitBus KAT Components Click on the diagram to enlarge, or follow this link for detailed documentation Introduction Welcome to the BigBitBus Kuberne

null 51 Oct 16, 2022
Define and run multi-container applications with Docker

Docker Compose Docker Compose is a tool for running multi-container applications on Docker defined using the Compose file format. A Compose file is us

Docker 28.2k Jan 8, 2023
gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.

Gunicorn Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn

Benoit Chesneau 8.7k Jan 8, 2023
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
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
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
Coding For Entrepreneurs 100 Jan 1, 2023
Python IMDB Docker - A docker tutorial to containerize a python script.

Python_IMDB_Docker A docker tutorial to containerize a python script. Build the docker in the current directory: docker build -t python-imdb . Run the

Sarthak Babbar 1 Dec 30, 2021
Cross-platform lib for process and system monitoring in Python

Home Install Documentation Download Forum Blog Funding What's new Summary psutil (process and system utilities) is a cross-platform library for retrie

Giampaolo Rodola 9k Jan 2, 2023
A Python library for the Docker Engine API

Docker SDK for Python A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run c

Docker 6.1k Dec 31, 2022
The leading native Python SSHv2 protocol library.

Paramiko Paramiko: Python SSH module Copyright: Copyright (c) 2009 Robey Pointer <[email protected]> Copyright: Copyright (c) 2020 Jeff Forcier <

null 8.1k Jan 4, 2023
Official Python client library for kubernetes

Kubernetes Python Client Python client for the kubernetes API. Installation From source: git clone --recursive https://github.com/kubernetes-client/py

Kubernetes Clients 5.4k Jan 2, 2023
Python job scheduling for humans.

schedule Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax. A simple to use API for

Dan Bader 10.4k Jan 2, 2023
A cron monitoring tool written in Python & Django

Healthchecks Healthchecks is a cron job monitoring service. It listens for HTTP requests and email messages ("pings") from your cron jobs and schedule

Healthchecks 5.8k Jan 2, 2023
Remote Desktop Protocol in Twisted Python

RDPY Remote Desktop Protocol in twisted python. RDPY is a pure Python implementation of the Microsoft RDP (Remote Desktop Protocol) protocol (client a

Sylvain Peyrefitte 1.6k Dec 30, 2022