This page contains descriptions of gofu commands and practical examples of how to use them. It aims to help you start cooking with gofu with little experience. If you have a use case not specified here, create a pull request and help us improve this documentation!
- Start a process - gofu run
- List processes - gofu ps (gofu list)
- Inspect a process - gofu inspect
- Stop a process - gofu stop
- Restart a process - gofu restart
- Remove a process - gofu rm (gofu remove)
- Update a process - gofu update
This command starts a new gofu-managed process, it will be created as a child process of gofu's daemon.
Usage: gofu run [FLAG ...] COMMAND [ARGUMENT ...]
Flags:
--directory string set working directory for the process
-e, --env stringArray set an environment variable, usage: -e FOO=BAR -e HELLO=WORLD
--env-file stringArray read environment variables from a file, usage: --env-file default.env --env-file local.env
-h, --help help for run
--max-retries uint32 max number of restart tries
-n, --name string set the process name
-r, --restart automatically restart a process when it exits
--restart-delay duration delay between automatic restarts
-s, --save start the process on system startup
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
gofu run --save $COMMAND
gofu run -s $COMMAND
Note: You can set --restart-delay
to 0
, making the process restart without any delay when it exits. But beware of cases where the process can exit on its startup, making gofu's process manager spam the system with new processes.
gofu run --save --restart --restart-delay 1s --max-retries 0 $COMMAND
gofu run -s -r --restart-delay 1s --max-retries 0 $COMMAND
Note: Every flag after the --
will be passed to the process. If you want to pass regular arguments, you can just write them after the $COMMAND
.
gofu run $COMMAND -- myargumentvalue --foo=bar -abc
gofu run $COMMAND myargumentvalue foo bar
gofu run -e FOO=BAR --env-file=/path/to/file.env $COMMAND
gofu run node /absolute/path/index.js
This command lists all gofu-managed processes.
Usage: gofu ps [FLAG ...]
gofu list [FLAG ...]
Flags:
-h, --help help for ps
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
gofu ps -o prettyjson
This commands provides detailed information about a gofu-managed process.
Usage: gofu inspect [FLAG ...] {NAME|PID}
Flags:
-h, --help help for inspect
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
This command stops a gofu-managed process.
Usage: gofu stop [FLAG ...] {NAME|PID}
Flags:
-h, --help help for stop
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
gofu stop 80s-anime-collection-backup
This command restarts a gofu-managed process.
Usage: gofu restart [FLAG ...] {NAME|PID}
Flags:
-h, --help help for restart
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
Usage: gofu rm [FLAG ...] {NAME|PID}
gofu remove [FLAG ...] {NAME|PID}
Flags:
-h, --help help for rm
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
gofu rm --force --always-yes $NAME
gofu rm -f -y $NAME
This command updates existing gofu-managed process with specified configuration properties.
Usage: gofu update [FLAG ...] {NAME|PID}
Flags:
--directory string update the working directory of a process
-h, --help help for update
--max-retries uint32 update the max number of restart tries (default 1)
-n, --name string update the name of a process
-r, --restart update whether a process should be automatically restarted (default true)
--restart-delay duration update the delay between automatic restarts
-s, --save update whether a process should be started on system startup
-o, --output string output format (text, json, or prettyjson) (default "text")
--timeout duration timeout for requests to the daemon (default 1m30s)
gofu update --name $NEW_NAME $NAME
gofu update -n $NEW_NAME $NAME
gofu update --save $NAME
gofu update -s $NAME