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

[service-manager] Add more process compose yamls #663

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions internal/impl/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ func (d *Devbox) StartProcessManager(ctx context.Context) error {
}
processComposePath, err := utilityLookPath("process-compose")
if err != nil {
fmt.Fprintln(d.writer, "Installing process-compose. This may take a minute but will only happen once.")
if err = addDevboxUtilityPackage("process-compose"); err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions internal/impl/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import (

"github.com/pkg/errors"
"go.jetpack.io/devbox/internal/nix"
"go.jetpack.io/devbox/internal/planner/plansdk"
"go.jetpack.io/devbox/internal/xdg"
)

// we need a more modern commit to get version of process-compose we want
// once the default nixpkgs commit is updated, we can remove this
const nixpkgsUtilityCommit = "f7475ce8950b761d80a13f3f81d2c23fce60c1dd"

// addDevboxUtilityPackage adds a package to the devbox utility profile.
// It's used to install applications devbox might need, like process-compose
// This is an alternative to a global install which would modify a user's
Expand All @@ -19,7 +22,7 @@ func addDevboxUtilityPackage(pkg string) error {
if err != nil {
return err
}
return nix.ProfileInstall(profilePath, plansdk.DefaultNixpkgsCommit, pkg)
return nix.ProfileInstall(profilePath, nixpkgsUtilityCommit, pkg)
}

func utilityLookPath(binName string) (string, error) {
Expand Down
3 changes: 3 additions & 0 deletions plugins/apache/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule log_config_module modules/mod_log_config.so

<IfModule unixd_module>
User daemon
Expand All @@ -37,6 +38,8 @@ DocumentRoot "${HTTPD_CONFDIR}/../web"
Require all denied
</Files>
ErrorLog "${HTTPD_ERROR_LOG_FILE}"
LogFormat "%h %l %u %t \"%r\" %>s %b" access
CustomLog "${HTTPD_ACCESS_LOG_FILE}" access
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
Expand Down
15 changes: 15 additions & 0 deletions plugins/apache/process-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "0.5"

processes:
apache:
command: "echo \"Apache starting on port $HTTPD_PORT\ http://localhost:$HTTPD_PORT\" && apachectl start -f $HTTPD_CONFDIR/httpd.conf -D FOREGROUND"
availability:
restart: "always"
apache-error:
command: "tail -f $HTTPD_ERROR_LOG_FILE"
availability:
restart: "always"
Comment on lines +8 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say the user wants to view these error logs, what command should they run to get the output from this tail -f ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can tail -f directly or they can use devbox service manager and get a UI that looks like this:

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that's neat

apache-access:
command: "tail -f $HTTPD_ACCESS_LOG_FILE"
availability:
restart: "always"
4 changes: 3 additions & 1 deletion plugins/apacheHttpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"HTTPD_DEVBOX_CONFIG_DIR": "{{ .DevboxProjectDir }}",
"HTTPD_CONFDIR": "{{ .DevboxDir }}",
"HTTPD_ERROR_LOG_FILE": "{{ .Virtenv }}/error.log",
"HTTPD_ACCESS_LOG_FILE": "{{ .Virtenv }}/access.log",
"HTTPD_PORT": "8080"
},
"create_files": {
"{{ .DevboxDir }}/httpd.conf": "apache/httpd.conf",
"{{ .DevboxDirRoot }}/web/index.html": "web/index.html"
"{{ .DevboxDirRoot }}/web/index.html": "web/index.html",
"{{ .Virtenv }}/process-compose.yaml": "apache/process-compose.yaml"
},
"services": {
"apache": {
Expand Down
3 changes: 2 additions & 1 deletion plugins/php.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"PHPFPM_PORT": "8082"
},
"create_files": {
"{{ .DevboxDir }}/php-fpm.conf": "php/php-fpm.conf"
"{{ .DevboxDir }}/php-fpm.conf": "php/php-fpm.conf",
"{{ .Virtenv }}/process-compose.yaml": "php/process-compose.yaml"
},
"services": {
"php-fpm": {
Expand Down
8 changes: 8 additions & 0 deletions plugins/php/process-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "0.5"

processes:
php-fpm:
command: "php-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonize"
availability:
restart: "always"