├── .gitignore ├── install ├── post-build-buildstep └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | IMAGE="progrium/buildstep" 5 | 6 | CMD="apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*" 7 | 8 | ID=$(docker run -d $IMAGE /bin/sh -c "$CMD") 9 | docker attach $ID 10 | test $(docker wait $ID) -eq 0 11 | docker commit $ID $IMAGE > /dev/null 12 | -------------------------------------------------------------------------------- /post-build-buildstep: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | APP="$1"; IMAGE="dokku/$APP" 3 | 4 | 5 | read -d '' exec_runner <<'EOF' 6 | #!/bin/bash 7 | 8 | set -e 9 | app_dir=/app 10 | export HOME=$app_dir 11 | cd \$HOME 12 | 13 | for file in .profile.d/*; do source \$file; done 14 | hash -r 15 | "\$@" 16 | EOF 17 | 18 | read -d '' start_runner <<'EOF' 19 | #!/bin/bash 20 | 21 | set -e 22 | app_dir=/app 23 | user_name=$(grep -o '^u[0-9]\\{4,5\\}' /etc/passwd) 24 | : ${user_name:="www-data"} 25 | 26 | export HOME=$app_dir 27 | chown -R $user_name:$user_name $app_dir 28 | 29 | hash -r 30 | cd \$HOME 31 | 32 | cat << CONF > supervisord.conf 33 | [supervisord] 34 | loglevel=debug 35 | nodaemon=true 36 | CONF 37 | 38 | while read line || [ -n "\$line" ] 39 | do 40 | if [[ "\$line" =~ ^([A-Za-z0-9_-]+):\s*(.+)$ ]] 41 | then 42 | name=\${line%%:*} 43 | command=\${line#*: } 44 | cat << CONF >> supervisord.conf 45 | [program:\${name}] 46 | command=/exec sh -c "\${command}" 47 | autostart=true 48 | autorestart=true 49 | stopsignal=QUIT 50 | 51 | CONF 52 | fi 53 | done < "Procfile" 54 | 55 | 56 | 57 | setuidgid $user_name supervisord -c supervisord.conf 58 | EOF 59 | 60 | set -e 61 | 62 | # Check for Procfile 63 | ID=$(docker run -d $IMAGE test -f app/Procfile) 64 | if [ $(docker wait $ID) -ne 0 ]; then 65 | exit 0 66 | fi 67 | 68 | echo "-----> Preparing Supervisor ..." 69 | 70 | CMD="rm /exec && \ 71 | dpkg -s supervisor > /dev/null 2>&1 || \ 72 | (apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*)" 73 | 74 | ID=$(docker run -i -a stdin $IMAGE /bin/bash -c "$CMD") 75 | test $(docker wait $ID) -eq 0 76 | docker commit $ID $IMAGE > /dev/null 77 | 78 | echo "-----> Injecting Supervisor ..." 79 | 80 | CMD="cat > /exec && \ 81 | chmod +x /exec" 82 | 83 | ID=$(echo "$exec_runner" | docker run -i -a stdin $IMAGE /bin/bash -c "$CMD") 84 | test $(docker wait $ID) -eq 0 85 | docker commit $ID $IMAGE > /dev/null 86 | 87 | CMD="cat > /start && \ 88 | chmod +x /start" 89 | 90 | ID=$(echo "$start_runner" | docker run -i -a stdin $IMAGE /bin/bash -c "$CMD") 91 | test $(docker wait $ID) -eq 0 92 | docker commit $ID $IMAGE > /dev/null 93 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dokku-supervisord 2 | 3 | > Deprecated as of Dokku 0.3.14 (process management) and 0.7.0 (restart policies) 4 | 5 | dokku-supervisord is a plugin for [dokku][dokku] that injects 6 | [supervisord][super] to run applications. It will convert a normal Procfile to 7 | supervisord.conf format when starting the application. 8 | 9 | Normally, dokku only runs the `web` process within Procfile. The 10 | dokku-supervisord plugin will run all process types (web, worker, etc.) and 11 | will restart crashed applications. 12 | 13 | # Not compatible with dokku 0.4+ 14 | 15 | As of dokku 0.4, plugins require a `plugin.toml` file. dokku-supervisord will not install correctly. Also, the functionality of multiple proceses and restarting is built into dokku now and should not require a plugin. See [issue #30](https://github.com/statianzo/dokku-supervisord/issues/30) for details. If you're still interested in using supervisord past dokku 0.4 check out [dokku-logging-supervisord](https://github.com/sehrope/dokku-logging-supervisord). 16 | 17 | ## Installation 18 | 19 | ```sh 20 | git clone https://github.com/statianzo/dokku-supervisord.git /var/lib/dokku/plugins/dokku-supervisord 21 | dokku plugins-install 22 | ``` 23 | 24 | All future deployments will use supervisord to start all processes. 25 | 26 | ## v0.4.0 breaking change 27 | 28 | v0.4.0 renamed the `post-release` to `post-build-buildstep` to keep compatibility with upstream dokku. If you're using an older version of dokku, be sure to pin your version to v0.3.x. 29 | 30 | ## Docker 0.10 support 31 | 32 | dokku-supervisord v0.3.0 changed the expected namespace from "app" to "dokku" 33 | to support Docker 0.10. See details within the [dokku issue][docker10]. If 34 | you're using a dokku version from before [this commit][docker10commit], stick 35 | with v0.2.x of dokku-supervisord. 36 | 37 | ## License 38 | 39 | The MIT License (MIT) 40 | 41 | Copyright (c) 2013-2014 Jason Staten 42 | 43 | Permission is hereby granted, free of charge, to any person obtaining a copy 44 | of this software and associated documentation files (the "Software"), to deal 45 | in the Software without restriction, including without limitation the rights 46 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 47 | copies of the Software, and to permit persons to whom the Software is 48 | furnished to do so, subject to the following conditions: 49 | 50 | The above copyright notice and this permission notice shall be included in 51 | all copies or substantial portions of the Software. 52 | 53 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 54 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 55 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 56 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 57 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 58 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 59 | SOFTWARE. 60 | 61 | [dokku]: https://github.com/progrium/dokku 62 | [super]: http://supervisord.org 63 | [docker10]: https://github.com/progrium/dokku/issues/533 64 | [docker10commit]: https://github.com/progrium/dokku/commit/2474844856ab5c53398005ebc455eb53676ac5d5 65 | --------------------------------------------------------------------------------