Skip to content
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
18 changes: 18 additions & 0 deletions internal/boxcli/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,17 @@ func ServicesCmd() *cobra.Command {
},
}

restartCommand := &cobra.Command{
Use: "restart [service]...",
Short: "Restarts service. If no service is specified, restarts all services",
RunE: func(cmd *cobra.Command, args []string) error {
return restartServices(cmd, args, flags)
},
}

flags.config.register(servicesCommand)
servicesCommand.AddCommand(lsCommand)
servicesCommand.AddCommand(restartCommand)
servicesCommand.AddCommand(startCommand)
servicesCommand.AddCommand(stopCommand)
return servicesCommand
Expand Down Expand Up @@ -118,3 +127,12 @@ func serviceNames(box devbox.Devbox) ([]string, error) {
}
return names, nil
}

func restartServices(
cmd *cobra.Command,
services []string,
flags servicesCmdFlags,
) error {
_ = stopServices(cmd, services, flags)
return startServices(cmd, services, flags)
}
2 changes: 2 additions & 0 deletions internal/plugin/pkgcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (m *Manager) CreateFilesAndShowReadme(pkg, rootDir string) error {
}
var buf bytes.Buffer
if err = t.Execute(&buf, map[string]string{
"DevboxConfigDir": rootDir,
"DevboxDir": filepath.Join(rootDir, devboxDirName, pkg),
"DevboxDirRoot": filepath.Join(rootDir, devboxDirName),
"DevboxProfileDefault": filepath.Join(rootDir, nix.ProfilePath),
Expand Down Expand Up @@ -144,6 +145,7 @@ func buildConfig(pkg, rootDir, content string) (*config, error) {
}
var buf bytes.Buffer
if err = t.Execute(&buf, map[string]string{
"DevboxConfigDir": rootDir,
"DevboxDir": filepath.Join(rootDir, devboxDirName, pkg),
"DevboxDirRoot": filepath.Join(rootDir, devboxDirName),
"DevboxProfileDefault": filepath.Join(rootDir, nix.ProfilePath),
Expand Down
12 changes: 6 additions & 6 deletions plugins/apache/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ LoadModule alias_module modules/mod_alias.so
Require all denied
</Directory>

DocumentRoot "{{ .DevboxDirRoot }}/web"
<Directory "{{ .DevboxDirRoot }}/web">
DocumentRoot "${HTTPD_CONFDIR}/../web"
<Directory "${HTTPD_CONFDIR}/../web">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
Expand All @@ -36,7 +36,7 @@ DocumentRoot "{{ .DevboxDirRoot }}/web"
<Files ".ht*">
Require all denied
</Files>
ErrorLog "${HTTPD_CONFDIR}/error.log"
ErrorLog "${HTTPD_ERROR_LOG_FILE}"
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
Expand All @@ -46,9 +46,9 @@ ErrorLog "${HTTPD_CONFDIR}/error.log"
ServerName php_localhost

UseCanonicalName Off
DocumentRoot "{{ .DevboxDirRoot }}/web"
DocumentRoot "${HTTPD_CONFDIR}/../web"

<Directory "{{ .DevboxDirRoot }}/web">
<Directory "${HTTPD_CONFDIR}/../web">
Options All
AllowOverride All
<IfModule mod_authz_host.c>
Expand All @@ -57,7 +57,7 @@ ErrorLog "${HTTPD_CONFDIR}/error.log"
</Directory>

## Added for php-fpm
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:8082/{{ .DevboxDirRoot }}/web/$1
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:8082/${HTTPD_DEVBOX_CONFIG_DIR}/devbox.d/web/$1
DirectoryIndex index.html

</VirtualHost>
2 changes: 2 additions & 0 deletions plugins/apacheHttpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.1",
"readme": "If you with to edit the config file, please copy it out of the .devbox directory.",
"env": {
"HTTPD_DEVBOX_CONFIG_DIR": "{{ .DevboxConfigDir }}",
"HTTPD_CONFDIR": "{{ .DevboxDir }}",
"HTTPD_ERROR_LOG_FILE": "{{ .Virtenv }}/error.log",
"HTTPD_PORT": "8080"
},
"create_files": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ server {
listen 80;
listen [::]:80;
server_name localhost;
root {{ .DevboxDirRoot }}/web;
root ../../../devbox.d/web;

error_log error.log error;
access_log access.log;
Expand Down
2 changes: 2 additions & 0 deletions plugins/php.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"match": "^php[0-9]*$",
"readme": "PHP is compiled with default extensions. If you would like to use non-default extensions you can add them with devbox add php81Extensions.{extension} . For example, for the memcache extension you can do `devbox add php81Extensions.memcached`.",
"env": {
"PHPFPM_ERROR_LOG_FILE": "{{ .Virtenv }}/php-fpm.log",
"PHPFPM_PID_FILE": "{{ .Virtenv }}/php-fpm.log",
"PHPFPM_PORT": "8082"
},
"create_files": {
Expand Down
4 changes: 2 additions & 2 deletions plugins/php/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[global]
pid = {{ .Virtenv }}/php-fpm.pid
error_log = {{ .Virtenv }}/php-fpm.log
pid = ${PHPFPM_PID_FILE}
error_log = ${PHPFPM_ERROR_LOG_FILE}
daemonize = yes

[www]
Expand Down