Skip to content

Commit 1c807a7

Browse files
author
Takashi Matsuo
committed
Install wp-cli and disabled pseudo cron behavior.
1 parent 9f7c740 commit 1c807a7

File tree

9 files changed

+35
-62
lines changed

9 files changed

+35
-62
lines changed

managed_vms/wordpress/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
my-wordpress-project

managed_vms/wordpress/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ running):
114114

115115
```
116116
$ cd my-wordpress-project
117-
$ php -S localhost:8000 -t wordpress wp.php
117+
$ vendor/bin/wp(.bat) server --path=wordpress
118118
```
119119

120-
Then access http://localhost:8000/. Follow the installation steps,
120+
Then access http://localhost:8080/. Follow the installation steps,
121121
create the admin user and its password. Login to the Dashboard and
122122
update if any of the plugins have update. I’m assuming that the local
123123
network is secure here. If you think differently, maybe you can first
@@ -133,7 +133,7 @@ Use the shell script wrapper for deployment as follows:
133133
```
134134
$ sh deploy_wrapper.sh \
135135
gcloud preview app deploy \
136-
--promote --stop-previous-version app.yaml
136+
--promote --stop-previous-version app.yaml cron.yaml
137137
```
138138

139139
Then access your site, use the username and the password you created
@@ -170,7 +170,14 @@ see the following Batcache stats in the HTML source:
170170
Because the wp-content directory on the server is read-only, you have
171171
to do this locally. Run WordPress locally and update plugins/themes in
172172
the local Dashboard, then deploy, then activate them in the production
173-
Dashboard.
173+
Dashboard. You can also use the `wp-cli` utility as follows:
174+
175+
```
176+
# To update all the plugins
177+
$ vendor/bin/wp plugin update --all --path=wordpress
178+
# To update all the themes
179+
$ vendor/bin/wp theme update --all --path=wordpress
180+
```
174181

175182
### Remove plugins/themes
176183

managed_vms/wordpress/src/Project.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ public function runComposer()
8585
{
8686
chdir($this->dir);
8787
exec(
88-
'composer install --no-interaction --no-progress --no-ansi',
88+
'composer update --no-interaction --no-progress --no-ansi',
8989
$output, $ret);
9090
$this->info = array_merge($this->info, $output);
9191
if ($ret !== 0) {
92-
$this->info[] = 'Failed to run composer install in ' . $dir
92+
$this->info[] = 'Failed to run composer update in ' . $dir
9393
. '. Please run it by yourself before running WordPress.';
9494
}
9595
}

managed_vms/wordpress/src/WordPressSetup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
124124
);
125125
$copyFiles = array(
126126
'app.yaml' => '/',
127+
'cron.yaml' => '/',
127128
'composer.json' => '/',
128129
'deploy_wrapper.sh' => '/',
129130
'Dockerfile' => '/',
130131
'gcs-media.php' => '/wordpress/wp-content/plugins/',
131132
'nginx-app.conf' => '/',
132133
'php.ini' => '/',
133134
'wp-config.php' => '/wordpress/',
134-
'wp.php' => '/'
135135
);
136136
$authKeys = array(
137137
'auth_key', 'secure_auth_key', 'logged_in_key', 'nonce_key',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"require": {
33
"google/appengine-php-sdk": "^1.9"
4+
},
5+
"require-dev": {
6+
"wp-cli/wp-cli": "^0.22.0"
47
}
58
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cron:
2+
- description: wordpress cron tasks
3+
url: /wp-cron.php
4+
schedule: every 15 minutes

managed_vms/wordpress/src/files/wp-config.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,25 @@
3535
// Cache settings
3636
define('WP_CACHE', ON_MVM);
3737

38+
// Disable pseudo cron behavior
39+
define('DISABLE_WP_CRON', true);
40+
41+
if (isset($_SERVER['HTTP_HOST'])) {
42+
define('HTTP_HOST', $_SERVER['HTTP_HOST']);
43+
} else {
44+
define('HTTP_HOST', 'localhost');
45+
}
46+
3847
$memcached_servers = array(
3948
'default' => array(
4049
getenv('MEMCACHE_PORT_11211_TCP_ADDR')
4150
. ':' . getenv('MEMCACHE_PORT_11211_TCP_PORT')
4251
)
4352
);
4453

45-
// Auto detect the URL fails.
46-
define('WP_HOME', ON_MVM ? 'https://' . $_SERVER['HTTP_HOST']
47-
: 'http://' . $_SERVER['HTTP_HOST']);
48-
define('WP_SITEURL', ON_MVM ? 'https://' . $_SERVER['HTTP_HOST']
49-
: 'http://' . $_SERVER['HTTP_HOST']);
54+
// Use https on MVMs.
55+
define('WP_HOME', ON_MVM ? 'https://' . HTTP_HOST : 'http://' . HTTP_HOST);
56+
define('WP_SITEURL', ON_MVM ? 'https://' . HTTP_HOST : 'http://' . HTTP_HOST);
5057

5158
// Need this for cookies.
5259
define('FORCE_SSL_ADMIN', ON_MVM);

managed_vms/wordpress/src/files/wp.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

managed_vms/wordpress/tests/DeployTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function deploy($project_id, $e2e_test_version)
6767
"sh $target/deploy_wrapper.sh gcloud -q preview app deploy "
6868
. "--version $e2e_test_version "
6969
. "--project $project_id --no-promote "
70-
. "$target/app.yaml",
70+
. "$target/app.yaml $target/cron.yaml",
7171
$output,
7272
$ret
7373
);

0 commit comments

Comments
 (0)