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)
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
Docker Container wallstreetbets-sentiment-analysis

Docker Container wallstreetbets-sentiment-analysis A docker container using restful endpoints exposed on port 5000 "/analyze" to gather sentiment anal

145 Nov 22, 2022
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 02, 2023
A little script and trick to make your heroku app run forever without being concerned about dyno hours.

A little script and trick to make your heroku app run forever without being concerned about dyno hours.

Tiararose Biezetta 152 Dec 25, 2022
A basic instruction for Kubernetes setup and understanding.

A basic instruction for Kubernetes setup and understanding Module ID Module Guide - Install Kubernetes Cluster k8s-install 3 Docker Core Technology mo

648 Jan 02, 2023
Changelog CI is a GitHub Action that enables a project to automatically generate changelogs

What is Changelog CI? Changelog CI is a GitHub Action that enables a project to automatically generate changelogs. Changelog CI can be triggered on pu

Maksudul Haque 106 Dec 25, 2022
Find-Xss - Termux Kurulum Dosyası Eklendi Eğer Hata Alıyorsanız Lütfen Resmini Çekip İnstagramdan Bildiriniz

FindXss Waf Bypass Eklendi !!! PRODUCER: Saep UPDATER: Aser-Vant Download: git c

Aser 2 Apr 17, 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

51 Oct 16, 2022
RMRK spy bot for RMRK hackathon

rmrk_spy_bot RMRK spy bot https://t.me/RMRKspyBot for rmrk hacktoberfest https://rmrk.devpost.com/ Birds and items price and rarity estimation Reports

Victor Ryabinin 2 Sep 06, 2022
Ansible for DevOps examples.

Ansible for DevOps Examples This repository contains Ansible examples developed to support different sections of Ansible for DevOps, a book on Ansible

Jeff Geerling 6.6k Jan 08, 2023
Inferoxy is a service for quick deploying and using dockerized Computer Vision models.

Inferoxy is a service for quick deploying and using dockerized Computer Vision models. It's a core of EORA's Computer Vision platform Vision Hub that runs on top of AWS EKS.

94 Oct 10, 2022
Automate SSH in python easily!

RedExpect RedExpect makes automating remote machines over SSH very easy to do and is very fast in doing exactly what you ask of it. Based on ssh2-pyth

Red_M 19 Dec 17, 2022
Kubediff: a tool for Kubernetes to show differences between running state and version controlled configuration.

Kubediff: a tool for Kubernetes to show differences between running state and version controlled configuration.

Weaveworks 1.1k Dec 30, 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
Bash-based Python-venv convenience wrapper

venvrc Bash-based Python-venv convenience wrapper. Demo Install Copy venvrc file to ~/.venvrc, and add the following line to your ~/.bashrc file: # so

1 Dec 29, 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
🎡 Build Python wheels for all the platforms on CI with minimal configuration.

cibuildwheel Documentation Python wheels are great. Building them across Mac, Linux, Windows, on multiple versions of Python, is not. cibuildwheel is

Python Packaging Authority 1.3k Jan 02, 2023
Flexible and scalable monitoring framework

Presentation of the Shinken project Welcome to the Shinken project. Shinken is a modern, Nagios compatible monitoring framework, written in Python. It

Gabès Jean 1.1k Dec 18, 2022
A Simple script to hunt unused Kubernetes resources.

K8SPurger A Simple script to hunt unused Kubernetes resources. Release History Release 0.3 Added Ingress Added Services Account Adding RoleBindding Re

Yogesh Kunjir 202 Nov 19, 2022
A declarative Kubeflow Management Tool inspired by Terraform

🍭 KRSH is Alpha version, so many bugs can be reported. If you find a bug, please write an Issue and grow the project together! A declarative Kubeflow

Riiid! 128 Oct 18, 2022