# https://pitchfork.jdx.dev/ llms-full.txt <|firecrawl-page-1-lllmstxt|> ## Pitchfork Daemons Documentation [Skip to content](https://pitchfork.jdx.dev/#VPContent) # pitchfork Daemons with DX [Getting Started](https://pitchfork.jdx.dev/getting-started.html) [CLI Reference](https://pitchfork.jdx.dev/cli.html) ![pitchfork logo](https://pitchfork.jdx.dev/assets/logo.CjqAML_x.png) <|firecrawl-page-2-lllmstxt|> ## Integrating Pitchfork with Mise [Skip to content](https://pitchfork.jdx.dev/mise.html#VPContent) Return to top # Integrating pitchfork with mise [​](https://pitchfork.jdx.dev/mise.html\#integrating-pitchfork-with-mise) [mise](https://mise.jdx.dev/) is a project for installing/managing dev tools, managing environment variables, and running tasks. Unlike pitchfork, [mise tasks](https://mise.jdx.dev/tasks/) do not run in the background however they offer a lot of functionality you won't find in pitchfork. It's encouraged to define relatively simple daemons that just call `mise run` to launch the daemon as a mise task. To do so, put the following into `pitchfork.toml`: toml ``` [daemons.docs] run = "mise run docs:dev" ``` And in `mise.toml` you can define how `mise run docs:dev` gets setup and behaves: toml ``` [env] NODE_ENV = "development" [tools] node = "20" [tasks."docs:setup"] run = "npm install" [tasks."docs:dev"] run = "node docs/index.js" depends = ["docs:setup"] ``` <|firecrawl-page-3-lllmstxt|> ## View Daemon Logs [Skip to content](https://pitchfork.jdx.dev/cli/logs#VPContent) On this page # `pitchfork logs` [​](https://pitchfork.jdx.dev/cli/logs\#pitchfork-logs) - **Usage**: `pitchfork logs [FLAGS] [ID]...` - **Aliases**: `l` Displays logs for daemon(s) ## Arguments [​](https://pitchfork.jdx.dev/cli/logs\#arguments) ### `[ID]...` [​](https://pitchfork.jdx.dev/cli/logs\#id) Show only logs for the specified daemon(s) ## Flags [​](https://pitchfork.jdx.dev/cli/logs\#flags) ### `-c --clear` [​](https://pitchfork.jdx.dev/cli/logs\#c-clear) Delete logs ### `-n ` [​](https://pitchfork.jdx.dev/cli/logs\#n-n) Show N lines of logs Set to 0 to show all logs ### `-t --tail` [​](https://pitchfork.jdx.dev/cli/logs\#t-tail) Show logs in real-time <|firecrawl-page-4-lllmstxt|> ## Pitchfork CLI Guide [Skip to content](https://pitchfork.jdx.dev/getting-started.html#VPContent) On this page # Pitchfork [​](https://pitchfork.jdx.dev/getting-started.html\#pitchfork) Pitchfork is a CLI for launching daemons with a focus on developer experience. WARNING This project is experimental. It works in basic situations but you'll undoubtedly encounter bugs. ## Use-cases [​](https://pitchfork.jdx.dev/getting-started.html\#use-cases) - launching development services like web APIs and databases - running rsync/unison to synchronize directories with a remote machine ## Features [​](https://pitchfork.jdx.dev/getting-started.html\#features) - only starting daemons if they have not already been started - starting daemons only when working in a project directory—then automatically stopping when you leave - \[coming soon\] automatically start daemons on boot - \[coming soon\] restarting daemons on failure ## Workflows [​](https://pitchfork.jdx.dev/getting-started.html\#workflows) Here's some common ways to use pitchfork. ## Installing pitchfork [​](https://pitchfork.jdx.dev/getting-started.html\#installing-pitchfork) [mise-en-place](https://mise.jdx.dev/) is the recommended way to install pitchfork. - mise-en-place – `mise use -g pitchfork` - cargo – `cargo install pitchfork-cli` - github - [https://github.com/jdx/pitchfork/releases](https://github.com/jdx/pitchfork/releases) ### Launching a one-off daemon [​](https://pitchfork.jdx.dev/getting-started.html\#launching-a-one-off-daemon) This workflow is an alternative to something like shell jobs— `mytask &`. [`pitchfork run`](https://pitchfork.jdx.dev/cli/run.html) just runs a process in the background: bash ``` pitchfork run docs -- npm start docs-dev-server ``` You need to label the daemon with a name, in this case "docs". Once it's started, "docs" will be how we reference it. If you run `pitchfork run docs "..."` again, it will not do anything if the daemon is still running—this way you can start one-off daemons without thinking if you've already done so. On [`pitchfork run`](https://pitchfork.jdx.dev/cli/run.html), pitchfork will emit the output of `npm start docs-dev-server` for a few seconds. If it fails during that time, it will exit non-zero to help you see if the daemon was configured/setup correctly. -- TODO this needs to be implemented ### Adding a daemon to a project [​](https://pitchfork.jdx.dev/getting-started.html\#adding-a-daemon-to-a-project) A project may have several daemons defined, this is configured in `pitchfork.toml` in the root of the project: toml ``` [daemons.redis] run = "redis-server" [daemons.api] run = "npm run server:api" [daemons.docs] run = "npm run server:docs" ``` You can start all the daemons with [`pitchfork start --all`](https://pitchfork.jdx.dev/cli/start.html) or individual ones with their name, e.g.: `pitchfork start redis`. If it's already started, nothing happens. You can also have pitchfork automatically start the daemons when entering the project in your terminal with the [shell hook](https://pitchfork.jdx.dev/getting-started.html#shell_hook). ### Adding a global daemon that runs on boot [​](https://pitchfork.jdx.dev/getting-started.html\#adding-a-global-daemon-that-runs-on-boot) TODO - implement this ## Shell hook [​](https://pitchfork.jdx.dev/getting-started.html\#shell-hook) Pitchfork has an optional shell hook for bash, zsh, and fish that will autostart and autostop daemons when entering/leaving projects. To install it, run the [`pitchfork activate`](https://pitchfork.jdx.dev/cli/activate.html) command below for your shell: bash ``` echo '$(pitchfork activate bash)' >> ~/.bashrc echo '$(pitchfork activate zsh)' >> ~/.zshrc echo 'pitchfork activate fish | source' >> ~/.config/fish/config.fish ``` Then when you restart your shell pitchfork will automatically start "autostart" daemons when entering the directory. daemons with "autostop" will stop daemons when leaving the directory after a bit of a delay if no terminal sessions are still inside the directory. TIP You can also have daemons only autostop. You can manually start them with [`pitchfork start`](https://pitchfork.jdx.dev/cli/start.html) then they will be stopped when you leave the directory. Here's a `pitchfork.toml` with this configured: toml ``` [daemons.api] run = "npm run server:api" auto = ["start", "stop"] ``` ## Logs [​](https://pitchfork.jdx.dev/getting-started.html\#logs) Logs for daemons started with pitchfork can be viewed with [`pitchfork logs`](https://pitchfork.jdx.dev/cli/logs.html) or by viewing the files directly in `~/.local/state/pitchfork/logs`. bash ``` $ pitchfork logs api [2021-08-01T12:00:00Z] api: starting [2021-08-01T12:00:01Z] api: listening on ``` You can also view the supervisor logs with `pitchfork logs pitchfork`. ## Supervisor [​](https://pitchfork.jdx.dev/getting-started.html\#supervisor) pitchfork has a supervisor daemon that automatically starts when you run commands like `pitchfork start|run`. You can manually start/stop it with [`pitchfork supervisor start|stop`](https://pitchfork.jdx.dev/cli/supervisor/start.html) or run a blocking supervisor with [`pitchfork supervisor run`](https://pitchfork.jdx.dev/cli/supervisor/run.html). This watches the daemons status, restarts them if the fail, and a bunch of other things. Ideally you shouldn't need to really be aware of it. It should just run in the background quietly. ## Configuration [​](https://pitchfork.jdx.dev/getting-started.html\#configuration) TODO: For now, you'll need to reference [the code](https://github.com/jdx/pitchfork/blob/main/src/env.rs). ## Troubleshooting [​](https://pitchfork.jdx.dev/getting-started.html\#troubleshooting) You can get extra logs by setting `PITCHFORK_LOG=debug` or `PITCHFORK_LOG=trace` in your environment. The supervisor will output extra logs but _only_ if this was set when it was started. To ensure the supervisor is printing debug logs, restart it with this set: bash ``` PITCHFORK_LOG=debug pitchfork supervisor start --force pitchfork logs pitchfork ``` TIP The `--force` is likely needed to kill an existing supervisor process. <|firecrawl-page-5-lllmstxt|> ## Pitchfork Supervisor Commands [Skip to content](https://pitchfork.jdx.dev/cli/supervisor.html#VPContent) On this page # `pitchfork supervisor` [​](https://pitchfork.jdx.dev/cli/supervisor.html\#pitchfork-supervisor) - **Usage**: `pitchfork supervisor ` - **Aliases**: `sup` Start, stop, and check the status of the pitchfork supervisor daemon ## Subcommands [​](https://pitchfork.jdx.dev/cli/supervisor.html\#subcommands) - [`pitchfork supervisor run [-f --force]`](https://pitchfork.jdx.dev/cli/supervisor/run.html) - [`pitchfork supervisor start [-f --force]`](https://pitchfork.jdx.dev/cli/supervisor/start.html) - [`pitchfork supervisor status`](https://pitchfork.jdx.dev/cli/supervisor/status.html) - [`pitchfork supervisor stop`](https://pitchfork.jdx.dev/cli/supervisor/stop.html) <|firecrawl-page-6-lllmstxt|> ## Pitchfork Config Management [Skip to content](https://pitchfork.jdx.dev/cli/config.html#VPContent) On this page # `pitchfork config` [​](https://pitchfork.jdx.dev/cli/config.html\#pitchfork-config) - **Usage**: `pitchfork config ` - **Aliases**: `cfg` manage/edit pitchfork.toml files without a subcommand, lists all pitchfork.toml files from the current directory ## Subcommands [​](https://pitchfork.jdx.dev/cli/config.html\#subcommands) - [`pitchfork config add [--autostart] [--autostop] [ARGS]...`](https://pitchfork.jdx.dev/cli/config/add.html) - [`pitchfork config remove `](https://pitchfork.jdx.dev/cli/config/remove.html) <|firecrawl-page-7-lllmstxt|> ## Run Daemon Command [Skip to content](https://pitchfork.jdx.dev/cli/run.html#VPContent) On this page # `pitchfork run` [​](https://pitchfork.jdx.dev/cli/run.html\#pitchfork-run) - **Usage**: `pitchfork run [-f --force] [-- RUN]...` - **Aliases**: `r` Runs a one-off daemon ## Arguments [​](https://pitchfork.jdx.dev/cli/run.html\#arguments) ### `` [​](https://pitchfork.jdx.dev/cli/run.html\#id) Name of the daemon to run ### `[-- RUN]...` [​](https://pitchfork.jdx.dev/cli/run.html\#run) ## Flags [​](https://pitchfork.jdx.dev/cli/run.html\#flags) ### `-f --force` [​](https://pitchfork.jdx.dev/cli/run.html\#f-force) <|firecrawl-page-8-lllmstxt|> ## Clean Command Overview [Skip to content](https://pitchfork.jdx.dev/cli/clean.html#VPContent) Return to top # `pitchfork clean` [​](https://pitchfork.jdx.dev/cli/clean.html\#pitchfork-clean) - **Usage**: `pitchfork clean` - **Aliases**: `c` Removes stopped/failed daemons from `pitchfork list`