Skip to content

Commit bd92912

Browse files
authored
[service-manager] Add more process compose yamls (#663)
## Summary This adds process compose for apache and php. It also fixes a hash to ensure we download a version of process compose that allows multiple config files to be merged. ## How was it tested? ```bash devbox add php apacheHttpd devbox services manager ```
1 parent f77daf6 commit bd92912

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed

internal/impl/devbox.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ func (d *Devbox) StartProcessManager(ctx context.Context) error {
628628
}
629629
processComposePath, err := utilityLookPath("process-compose")
630630
if err != nil {
631+
fmt.Fprintln(d.writer, "Installing process-compose. This may take a minute but will only happen once.")
631632
if err = addDevboxUtilityPackage("process-compose"); err != nil {
632633
return err
633634
}

internal/impl/util.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import (
66

77
"github.com/pkg/errors"
88
"go.jetpack.io/devbox/internal/nix"
9-
"go.jetpack.io/devbox/internal/planner/plansdk"
109
"go.jetpack.io/devbox/internal/xdg"
1110
)
1211

12+
// we need a more modern commit to get version of process-compose we want
13+
// once the default nixpkgs commit is updated, we can remove this
14+
const nixpkgsUtilityCommit = "f7475ce8950b761d80a13f3f81d2c23fce60c1dd"
15+
1316
// addDevboxUtilityPackage adds a package to the devbox utility profile.
1417
// It's used to install applications devbox might need, like process-compose
1518
// This is an alternative to a global install which would modify a user's
@@ -19,7 +22,7 @@ func addDevboxUtilityPackage(pkg string) error {
1922
if err != nil {
2023
return err
2124
}
22-
return nix.ProfileInstall(profilePath, plansdk.DefaultNixpkgsCommit, pkg)
25+
return nix.ProfileInstall(profilePath, nixpkgsUtilityCommit, pkg)
2326
}
2427

2528
func utilityLookPath(binName string) (string, error) {

plugins/apache/httpd.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ LoadModule proxy_module modules/mod_proxy.so
1515
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
1616
LoadModule dir_module modules/mod_dir.so
1717
LoadModule alias_module modules/mod_alias.so
18+
LoadModule log_config_module modules/mod_log_config.so
1819

1920
<IfModule unixd_module>
2021
User daemon
@@ -37,6 +38,8 @@ DocumentRoot "${HTTPD_CONFDIR}/../web"
3738
Require all denied
3839
</Files>
3940
ErrorLog "${HTTPD_ERROR_LOG_FILE}"
41+
LogFormat "%h %l %u %t \"%r\" %>s %b" access
42+
CustomLog "${HTTPD_ACCESS_LOG_FILE}" access
4043
<IfModule headers_module>
4144
RequestHeader unset Proxy early
4245
</IfModule>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "0.5"
2+
3+
processes:
4+
apache:
5+
command: "echo \"Apache starting on port $HTTPD_PORT\ http://localhost:$HTTPD_PORT\" && apachectl start -f $HTTPD_CONFDIR/httpd.conf -D FOREGROUND"
6+
availability:
7+
restart: "always"
8+
apache-error:
9+
command: "tail -f $HTTPD_ERROR_LOG_FILE"
10+
availability:
11+
restart: "always"
12+
apache-access:
13+
command: "tail -f $HTTPD_ACCESS_LOG_FILE"
14+
availability:
15+
restart: "always"

plugins/apacheHttpd.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"HTTPD_DEVBOX_CONFIG_DIR": "{{ .DevboxProjectDir }}",
77
"HTTPD_CONFDIR": "{{ .DevboxDir }}",
88
"HTTPD_ERROR_LOG_FILE": "{{ .Virtenv }}/error.log",
9+
"HTTPD_ACCESS_LOG_FILE": "{{ .Virtenv }}/access.log",
910
"HTTPD_PORT": "8080"
1011
},
1112
"create_files": {
1213
"{{ .DevboxDir }}/httpd.conf": "apache/httpd.conf",
13-
"{{ .DevboxDirRoot }}/web/index.html": "web/index.html"
14+
"{{ .DevboxDirRoot }}/web/index.html": "web/index.html",
15+
"{{ .Virtenv }}/process-compose.yaml": "apache/process-compose.yaml"
1416
},
1517
"services": {
1618
"apache": {

plugins/php.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"PHPFPM_PORT": "8082"
1010
},
1111
"create_files": {
12-
"{{ .DevboxDir }}/php-fpm.conf": "php/php-fpm.conf"
12+
"{{ .DevboxDir }}/php-fpm.conf": "php/php-fpm.conf",
13+
"{{ .Virtenv }}/process-compose.yaml": "php/process-compose.yaml"
1314
},
1415
"services": {
1516
"php-fpm": {

plugins/php/process-compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "0.5"
2+
3+
processes:
4+
php-fpm:
5+
command: "php-fpm -y {{ .DevboxDir }}/php-fpm.conf --nodaemonize"
6+
availability:
7+
restart: "always"
8+

0 commit comments

Comments
 (0)