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)
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
Helperpod - A CLI tool to run a Kubernetes utility pod with pre-installed tools that can be used for debugging/testing purposes inside a Kubernetes cluster

Helperpod is a CLI tool to run a Kubernetes utility pod with pre-installed tools that can be used for debugging/testing purposes inside a Kubernetes cluster.

Atakan Tatlı 2 Feb 05, 2022
Universal Command Line Interface for Amazon Web Services

aws-cli This package provides a unified command line interface to Amazon Web Services. Jump to: Getting Started Getting Help More Resources Getting St

Amazon Web Services 13.3k Jan 01, 2023
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
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
Azure plugins for Feast (FEAture STore)

Feast on Azure This project provides resources to enable running a feast feature store on Azure. Feast Azure Provider The Feast Azure provider acts li

Microsoft Azure 70 Dec 31, 2022
CI repo for building Skia as a shared library

Automated Skia builds This repo is dedicated to building Skia binaries for use in Skija. Prebuilt binaries Prebuilt binaries can be found in releases.

Humble UI 20 Jan 06, 2023
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
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
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
Prometheus exporter for AWS Simple Queue Service (SQS)

Prometheus SQS Exporter Prometheus exporter for AWS Simple Queue Service (SQS) Metrics Metric Description ApproximateNumberOfMessages Returns the appr

Gabriel M. Dutra 0 Jan 31, 2022
Supervisor process control system for UNIX

Supervisor Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. Supported Platf

Supervisor 7.6k Dec 31, 2022
Tools for writing awesome Fabric files

About fabtools includes useful functions to help you write your Fabric files. fabtools makes it easier to manage system users, packages, databases, et

1.3k Dec 30, 2022
CDK Template of Table Definition AWS Lambda for RDB

CDK Template of Table Definition AWS Lambda for RDB Overview This sample deploys Amazon Aurora of PostgreSQL or MySQL with AWS Lambda that can define

AWS Samples 5 May 16, 2022
Hw-ci - Hardware CD/CI and Development Container

Hardware CI & Dev Containter These containers were created for my personal hardware development projects and courses duing my undergraduate degree. Pl

Matthew Dwyer 6 Dec 25, 2022
CTF infrastructure deployment automation tool.

CTF infrastructure deployment automation tool. Focus on the challenges. Mirrored from

Fake News 1 Apr 12, 2022
sysctl/sysfs settings on a fly for Kubernetes Cluster. No restarts are required for clusters and nodes.

SysBindings Daemon Little toolkit for control the sysctl/sysfs bindings on Kubernetes Cluster on the fly and without unnecessary restarts of cluster o

Wallarm 19 May 06, 2022
DC/OS - The Datacenter Operating System

DC/OS - The Datacenter Operating System The easiest way to run microservices, big data, and containers in production. What is DC/OS? Like traditional

DC/OS 2.3k Jan 06, 2023
The low-level, core functionality of boto 3.

botocore A low-level interface to a growing number of Amazon Web Services. The botocore package is the foundation for the AWS CLI as well as boto3. On

the boto project 1.2k Jan 03, 2023