Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add background processes #83

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions src/devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,35 @@ pkgs.writeScriptBin "devenv" ''
if [ "$(cat $procfile)" = "" ]; then
echo "No 'processes' option defined."
exit 1
fi;

honcho_command="${pkgs.honcho}/bin/honcho start -f $procfile --env $procfileenv"

if [[ $# -eq 1 ]] && [[ $1 == "-d" ]]; then
echo "Starting background processes ..." 1>&2
echo "" 1>&2
nohup $honcho_command &> "$DEVENV_DIR/honcho.log" &
echo "$!" > "$DEVENV_DIR/honcho.pid"
else
echo "Starting processes ..." 1>&2
echo "" 1>&2
${pkgs.honcho}/bin/honcho start -f $procfile --env $procfileenv
$honcho_command
fi
;;
;;
down)
if [ -r "$DEVENV_DIR/honcho.pid" ]; then
echo "Stopping processes ..." 1>&2
echo "" 1>&2
kill $(cat "$DEVENV_DIR/honcho.pid")
rm "$DEVENV_DIR/honcho.pid"
else
echo "No running processes were found." 1>&2
echo "" 1>&2
fi;
JanLikar marked this conversation as resolved.
Show resolved Hide resolved
;;
logs)
$PAGER "$DEVENV_DIR/honcho.log"
;;
print-dev-env)
shell
echo "$env"
Expand Down Expand Up @@ -196,8 +219,11 @@ pkgs.writeScriptBin "devenv" ''
echo "shell CMD ARGS: Run CMD with ARGS in the developer environment. Useful when scripting."
echo "update: Update devenv.lock from devenv.yaml inputs. See http://devenv.sh/inputs/#locking-and-updating-inputs"
echo "up: Starts processes in foreground. See http://devenv.sh/processes"
echo "up -d: Starts processes in background."
echo "down: Stops background processes."
echo "logs: Shows logs of running background processes."
echo "gc: Removes old devenv generations. See http://devenv.sh/garbage-collection"
echo "ci: builds your developer environment and make sure all checks pass."
echo "ci: Builds your developer environment and make sure all checks pass."
echo "version: Display devenv version"
echo
exit 1
Expand Down