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 collection of beginner-friendly DevOps content

mansion Mansion is just a testing repo for learners to commit into open source project. These are the steps you need to learn: Please do not edit thes

Bryan Lim 62 Nov 30, 2022
Ralph is the CMDB / Asset Management system for data center and back office hardware.

Ralph Ralph is full-featured Asset Management, DCIM and CMDB system for data centers and back offices. Features: keep track of assets purchases and th

Allegro Tech 1.9k Jan 01, 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 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
NixOps is a tool for deploying to NixOS machines in a network or cloud.

NixOps NixOps is a tool for deploying to NixOS machines in a network or the cloud. Key features include: Declarative: NixOps determines and carries ou

Nix/Nixpkgs/NixOS 1.2k Jan 02, 2023
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
Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端

Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端 快速入门 配置证书 证书用于验证用户 Token。请确保这里的证书文件(cert.pem)与 Hackergame 平台 配置的证书相同,这样 Hackergame 平台为每个用户生成的 Token 才可以通

USTC Hackergame 68 Nov 09, 2022
Autoscaling volumes for Kubernetes (with the help of Prometheus)

Kubernetes Volume Autoscaler (with Prometheus) This repository contains a service that automatically increases the size of a Persistent Volume Claim i

DevOps Nirvana 142 Dec 28, 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
Self-hosted, easily-deployable monitoring and alerts service - like a lightweight PagerDuty

Cabot Maintainers wanted Cabot is stable and used by hundreds of companies and individuals in production, but it is not actively maintained. We would

Arachnys 5.4k Dec 23, 2022
HB Case Study

HB Case Study Envoy Proxy It is a modern Layer7(App) and Layer3(TCP) proxy Incredibly modernized version of reverse proxies like NGINX, HAProxy It is

Ilker Ispir 1 Oct 22, 2021
MicroK8s is a small, fast, single-package Kubernetes for developers, IoT and edge.

MicroK8s The smallest, fastest Kubernetes Single-package fully conformant lightweight Kubernetes that works on 42 flavours of Linux. Perfect for: Deve

Ubuntu 7.1k Jan 08, 2023
This Docker container is build to run on a server an provide an easy to use interface for every student to vote for their councilors

This Docker container is build to run on a server and provide an easy to use interface for every student to vote for their councilors.

Robin Adelwarth 7 Nov 23, 2022
A lobby boy will create a VPS server when you need one, and destroy it after using it.

Lobbyboy What is a lobby boy? A lobby boy is completely invisible, yet always in sight. A lobby boy remembers what people hate. A lobby boy anticipate

226 Dec 29, 2022
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 08, 2023
Organizing ssh servers in one shell.

NeZha (哪吒) NeZha is a famous chinese deity who can have three heads and six arms if he wants. And my NeZha tool is hoping to bring developer such mult

Zilin Zhu 8 Dec 20, 2021
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
Push Container Image To Docker Registry In Python

push-container-image-to-docker-registry 概要 push-container-image-to-docker-registry は、エッジコンピューティング環境において、特定のエッジ端末上の Private Docker Registry に特定のコンテナイメー

Latona, Inc. 3 Nov 04, 2021
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
Learning and experimenting with Kubernetes

Kubernetes Experiments This repository contains code that I'm using to learn and experiment with Kubernetes. 1. Environment setup minikube kubectl doc

Richard To 10 Dec 02, 2022