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

Rplace JSON with YAML #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 27 additions & 20 deletions clamp.defaults.13.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ apache:
options:
servername: "{{$.address}}"
listen: 80
pidfile: "{{$cwd}}/.clamp/tmp/httpd.pid"
lockfile: "{{$cwd}}/.clamp/tmp/accept.lock"
autoopen: false
errorlog: "{{$cwd}}/.clamp/logs/apache.error.log"
customlog: "{{$cwd}}/.clamp/logs/apache.access.log"
pidfile: "'{{$cwd}}/.clamp/tmp/httpd.pid'"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you wrap the pid file here in single quotes?

Copy link
Author

Choose a reason for hiding this comment

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

There were single quotes in the original JSON file. I converted it to YAML and kept it.

lockfile: "'{{$cwd}}/.clamp/tmp/accept.lock'",
conf: |
<Directory {{$cwd}}>
AllowOverride: All
</Directory>
ServerName {{$.apache.options.servername}}
Listen {{$.apache.options.listen}}
DocumentRoot {{$cwd}}
ServerRoot {{$cwd}}
DefaultRuntimeDir '{{$cwd}}/.clamp/tmp'
DefaultRuntimeDir "{{$cwd}}/.clamp/tmp"
User {{$whoami}}
Group _www

ServerRoot "{{$cwd}}"
DocumentRoot "{{$cwd}}"

LogLevel info
ErrorLog '{{$cwd}}/.clamp/logs/apache.error.log'
CustomLog '{{$cwd}}/.clamp/logs/apache.access.log' common
LogFormat "%h %l %u %t \"%r\" %>s %b" common
ErrorLog {{$.apache.options.errorlog}}
CustomLog {{$.apache.options.customlog}} common

AddType application/x-httpd-php .php
DirectoryIndex index.html index.php

SetEnv LOCAL_SERVER true
User {{$whoami}}
Group _www

LoadModule authz_core_module /usr/libexec/apache2/mod_authz_core.so
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule dir_module /usr/libexec/apache2/mod_dir.so
Expand All @@ -36,14 +42,15 @@ apache:
LoadModule rewrite_module /usr/libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/libexec/apache2/libphp5.so
LoadModule unixd_module /usr/libexec/apache2/mod_unixd.so

php_admin_value memory_limit {{$.memory}}
php_admin_value pdo_mysql.default_socket "{{$.mysql.options.socket}}"
php_admin_value mysql.default_socket: "{{$.mysql.options.socket}}"
php_admin_value mysqli.default_socket: "{{$.mysql.options.socket}}"
php_admin_value pdo_mysql.default_socket {{$.mysql.options.socket}}
php_admin_value mysql.default_socket: {{$.mysql.options.socket}}
php_admin_value mysqli.default_socket: {{$.mysql.options.socket}}

host:
options:
127.0.0.1: "{{$.address}}"
"127.0.0.1": "{{$.address}}"
mysql:
commands:
mysql: "$(brew --prefix mariadb)/bin/mysql"
Expand All @@ -58,9 +65,9 @@ mysql:
port: '3306'
lower_case_table_names: 2
basedir: "$(brew --prefix mariadb)"
datadir: "{{$cwd}}/.clamp/data"
socket: "{{$cwd}}/.clamp/tmp/mysql.sock"
pid-file: "{{$cwd}}/.clamp/tmp/mysql.pid"
log_error: "{{$cwd}}/.clamp/logs/mysql.error.log"
datadir: "'{{$cwd}}/.clamp/data'"
socket: "'{{$cwd}}/.clamp/tmp/mysql.sock'"
pid-file: "'{{$cwd}}/.clamp/tmp/mysql.pid'"
log_error: "'{{$cwd}}/.clamp/logs/mysql.error.log'"
max_binlog_size: 10M
max_allowed_packet: 32M
49 changes: 30 additions & 19 deletions clamp.defaults.14.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@ apache:
servername: "{{$.address}}"
listen: 80
autoopen: false
pidfile: "{{$cwd}}/.clamp/tmp/httpd.pid"
errorlog: "{{$cwd}}/.clamp/logs/apache.error.log"
customlog: "{{$cwd}}/.clamp/logs/apache.access.log"
pidfile: "'{{$cwd}}/.clamp/tmp/httpd.pid'"
conf: |
<Directory {{$cwd}}>
AllowOverride: All
</Directory>
ServerName {{$.apache.options.servername}}
Listen {{$.apache.options.listen}}
DocumentRoot {{$cwd}}
ServerRoot {{$cwd}}
DefaultRuntimeDir '{{$cwd}}/.clamp/tmp'
DefaultRuntimeDir "{{$cwd}}/.clamp/tmp"
User {{$whoami}}
Group _www

ServerRoot "{{$cwd}}"
DocumentRoot "{{$cwd}}"
<Directory "{{$cwd}}">
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>

LogLevel info
ErrorLog '{{$cwd}}/.clamp/logs/apache.error.log'
CustomLog '{{$cwd}}/.clamp/logs/apache.access.log' common
LogFormat "%h %l %u %t \"%r\" %>s %b" common
ErrorLog {{$.apache.options.errorlog}}
CustomLog {{$.apache.options.customlog}} common

AddType application/x-httpd-php .php
DirectoryIndex index.html index.php

SetEnv LOCAL_SERVER true
User {{$whoami}}
Group _www

LoadModule authz_core_module /usr/libexec/apache2/mod_authz_core.so
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule dir_module /usr/libexec/apache2/mod_dir.so
Expand All @@ -36,14 +46,15 @@ apache:
LoadModule rewrite_module /usr/libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/libexec/apache2/libphp5.so
LoadModule unixd_module /usr/libexec/apache2/mod_unixd.so

php_admin_value memory_limit {{$.memory}}
php_admin_value pdo_mysql.default_socket "{{$.mysql.options.socket}}"
php_admin_value mysql.default_socket: "{{$.mysql.options.socket}}"
php_admin_value mysqli.default_socket: "{{$.mysql.options.socket}}"
php_admin_value pdo_mysql.default_socket {{$.mysql.options.socket}}
php_admin_value mysql.default_socket: {{$.mysql.options.socket}}
php_admin_value mysqli.default_socket: {{$.mysql.options.socket}}

host:
options:
127.0.0.1: "{{$.address}}"
"127.0.0.1": "{{$.address}}"
mysql:
commands:
mysql: "$(brew --prefix mariadb)/bin/mysql"
Expand All @@ -58,9 +69,9 @@ mysql:
port: '3306'
lower_case_table_names: 2
basedir: "$(brew --prefix mariadb)"
datadir: "{{$cwd}}/.clamp/data"
socket: "{{$cwd}}/.clamp/tmp/mysql.sock"
pid-file: "{{$cwd}}/.clamp/tmp/mysql.pid"
log_error: "{{$cwd}}/.clamp/logs/mysql.error.log"
datadir: "'{{$cwd}}/.clamp/data'"
socket: "'{{$cwd}}/.clamp/tmp/mysql.sock'"
pid-file: "'{{$cwd}}/.clamp/tmp/mysql.pid'"
log_error: "'{{$cwd}}/.clamp/logs/mysql.error.log'"
max_binlog_size: 10M
max_allowed_packet: 32M
49 changes: 30 additions & 19 deletions clamp.defaults.15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@ apache:
servername: "{{$.address}}"
listen: 80
autoopen: false
pidfile: "{{$cwd}}/.clamp/tmp/httpd.pid"
errorlog: "{{$cwd}}/.clamp/logs/apache.error.log"
customlog: "{{$cwd}}/.clamp/logs/apache.access.log"
pidfile: "'{{$cwd}}/.clamp/tmp/httpd.pid'"
conf: |
<Directory {{$cwd}}>
AllowOverride: All
</Directory>
ServerName {{$.apache.options.servername}}
Listen {{$.apache.options.listen}}
DocumentRoot {{$cwd}}
ServerRoot {{$cwd}}
DefaultRuntimeDir '{{$cwd}}/.clamp/tmp'
DefaultRuntimeDir "{{$cwd}}/.clamp/tmp"
User {{$whoami}}
Group _www

ServerRoot "{{$cwd}}"
DocumentRoot "{{$cwd}}"
<Directory "{{$cwd}}">
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>

LogLevel info
ErrorLog '{{$cwd}}/.clamp/logs/apache.error.log'
CustomLog '{{$cwd}}/.clamp/logs/apache.access.log' common
LogFormat "%h %l %u %t \"%r\" %>s %b" common
ErrorLog {{$.apache.options.errorlog}}
CustomLog {{$.apache.options.customlog}} common

AddType application/x-httpd-php .php
DirectoryIndex index.html index.php

SetEnv LOCAL_SERVER true
User {{$whoami}}
Group _www

LoadModule authz_core_module /usr/libexec/apache2/mod_authz_core.so
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule dir_module /usr/libexec/apache2/mod_dir.so
Expand All @@ -36,14 +46,15 @@ apache:
LoadModule rewrite_module /usr/libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/libexec/apache2/libphp5.so
LoadModule unixd_module /usr/libexec/apache2/mod_unixd.so

php_admin_value memory_limit {{$.memory}}
php_admin_value pdo_mysql.default_socket "{{$.mysql.options.socket}}"
php_admin_value mysql.default_socket: "{{$.mysql.options.socket}}"
php_admin_value mysqli.default_socket: "{{$.mysql.options.socket}}"
php_admin_value pdo_mysql.default_socket {{$.mysql.options.socket}}
php_admin_value mysql.default_socket: {{$.mysql.options.socket}}
php_admin_value mysqli.default_socket: {{$.mysql.options.socket}}

host:
options:
127.0.0.1: "{{$.address}}"
"127.0.0.1": "{{$.address}}"
mysql:
commands:
mysql: "$(brew --prefix mariadb)/bin/mysql"
Expand All @@ -58,9 +69,9 @@ mysql:
port: '3306'
lower_case_table_names: 2
basedir: "$(brew --prefix mariadb)"
datadir: "{{$cwd}}/.clamp/data"
socket: "{{$cwd}}/.clamp/tmp/mysql.sock"
pid-file: "{{$cwd}}/.clamp/tmp/mysql.pid"
log_error: "{{$cwd}}/.clamp/logs/mysql.error.log"
datadir: "'{{$cwd}}/.clamp/data'"
socket: "'{{$cwd}}/.clamp/tmp/mysql.sock'"
pid-file: "'{{$cwd}}/.clamp/tmp/mysql.pid'"
log_error: "'{{$cwd}}/.clamp/logs/mysql.error.log'"
max_binlog_size: 10M
max_allowed_packet: 32M
49 changes: 30 additions & 19 deletions clamp.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@ apache:
servername: "{{$.address}}"
listen: 80
autoopen: false
pidfile: "{{$cwd}}/.clamp/tmp/httpd.pid"
errorlog: "{{$cwd}}/.clamp/logs/apache.error.log"
customlog: "{{$cwd}}/.clamp/logs/apache.access.log"
pidfile: "'{{$cwd}}/.clamp/tmp/httpd.pid'"
conf: |
<Directory {{$cwd}}>
AllowOverride: All
</Directory>
ServerName {{$.apache.options.servername}}
Listen {{$.apache.options.listen}}
DocumentRoot {{$cwd}}
ServerRoot {{$cwd}}
DefaultRuntimeDir '{{$cwd}}/.clamp/tmp'
DefaultRuntimeDir "{{$cwd}}/.clamp/tmp"
User {{$whoami}}
Group _www

ServerRoot "{{$cwd}}"
DocumentRoot "{{$cwd}}"
<Directory "{{$cwd}}">
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>

LogLevel info
ErrorLog '{{$cwd}}/.clamp/logs/apache.error.log'
CustomLog '{{$cwd}}/.clamp/logs/apache.access.log' common
LogFormat "%h %l %u %t \"%r\" %>s %b" common
ErrorLog {{$.apache.options.errorlog}}
CustomLog {{$.apache.options.customlog}} common

AddType application/x-httpd-php .php
DirectoryIndex index.html index.php

SetEnv LOCAL_SERVER true
User {{$whoami}}
Group _www

LoadModule authz_core_module /usr/libexec/apache2/mod_authz_core.so
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule dir_module /usr/libexec/apache2/mod_dir.so
Expand All @@ -36,14 +46,15 @@ apache:
LoadModule rewrite_module /usr/libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/libexec/apache2/libphp5.so
LoadModule unixd_module /usr/libexec/apache2/mod_unixd.so

php_admin_value memory_limit {{$.memory}}
php_admin_value pdo_mysql.default_socket "{{$.mysql.options.socket}}"
php_admin_value mysql.default_socket: "{{$.mysql.options.socket}}"
php_admin_value mysqli.default_socket: "{{$.mysql.options.socket}}"
php_admin_value pdo_mysql.default_socket {{$.mysql.options.socket}}
php_admin_value mysql.default_socket: {{$.mysql.options.socket}}
php_admin_value mysqli.default_socket: {{$.mysql.options.socket}}

host:
options:
127.0.0.1: "{{$.address}}"
"127.0.0.1": "{{$.address}}"
mysql:
commands:
mysql: "$(brew --prefix mariadb)/bin/mysql"
Expand All @@ -58,9 +69,9 @@ mysql:
port: '3306'
lower_case_table_names: 2
basedir: "$(brew --prefix mariadb)"
datadir: "{{$cwd}}/.clamp/data"
socket: "{{$cwd}}/.clamp/tmp/mysql.sock"
pid-file: "{{$cwd}}/.clamp/tmp/mysql.pid"
log_error: "{{$cwd}}/.clamp/logs/mysql.error.log"
datadir: "'{{$cwd}}/.clamp/data'"
socket: "'{{$cwd}}/.clamp/tmp/mysql.sock'"
pid-file: "'{{$cwd}}/.clamp/tmp/mysql.pid'"
log_error: "'{{$cwd}}/.clamp/logs/mysql.error.log'"
max_binlog_size: 10M
max_allowed_packet: 32M
13 changes: 11 additions & 2 deletions includes/Clamp/ApacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ApacheCommand extends \Clamp\Command
{
protected $parameter = '%1$s "%2$s"';
protected $parameter = '%2$s';
protected $autoopen = false;
protected $servername = null;
protected $port = "80";
Expand All @@ -18,12 +18,21 @@ public function executeStart(array $args = array(), array $options = array())
$this->_configureAutoopen($options);

$pid = array_get($options, 'pidfile');

if ($this->isRunning($this->getPath($pid))) {
$this->writeln('Apache server is already running', ConsoleKit\Colors::YELLOW);
} else {
$this->preparePaths($options);
$file = $this->buildConfigureFile(array_get($options, 'conf'));
exec($this->getConfig('$.apache.commands.httpd') . $this->buildParameters(['-f' => $file]) . ' > /dev/null &');
$parameters = [
"-f '$file'",
"-c \"pidfile $pid\"",
];
if (isset($options['lockfile'])) {
$parameters[] = "-c \"lockfile $options[lockfile]\"";
}

exec($this->getConfig('$.apache.commands.httpd') . ' ' . $this->buildParameters($parameters) . ' > /dev/null &');
$this->waitFor($this->getPath($pid));
$this->writeln('Apache server started', ConsoleKit\Colors::GREEN);
}
Expand Down
4 changes: 0 additions & 4 deletions includes/Clamp/ConfigOptionsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ public function getConfig($expr = null)
$expr = substr($expr, 2);
$value = array_get($this->config, $expr);

if (is_array($value) && count($value) == 1) {
$value = reset($value);
}

return $value;
}

Expand Down