Timzone set from init.php

General discussion forum for the Zend Server
Post Reply
Posts: 14
Joined: Tue Sep 22, 2015 10:05 am

Timzone set from init.php

Post by terr3089 » Wed Aug 10, 2016 11:08 am

I have a problem, I need date.timezone set to Europe/London which I can do via the admin GUI but if the server reboots it gets set back to UTC which causes problems

I am running Zend Server 8.5 on RHEL 7 on AWS

The date.timezone is being done via /root/zs-init/init.php which is run by /etc/rc.local

I can't see how I can control it

I can add a hack to /etc/rc.local using zs-manage but there must be a better way

Grateful for any ideas

Posts: 15
Joined: Sun Jul 17, 2011 3:17 pm
Location: Ramat Gan, Israel

Re: Timzone set from init.php

Post by dima_z_zend » Wed Aug 10, 2016 3:21 pm

You could write simple bash script that changes directive to be whatever you need and put it on S3 for example.
Then you can use userdata to pass your script, and it will be executed by zs-init automatically. Here is an example of such userdata:

Code: Select all

zs-init expects userdata to be a valid JSON object. For information about parameters that JSON object can have, read AWS User Data.
Dmitry Zbarski
Cloud Integration Engineer
Zend Technologies, Ltd.

Posts: 14
Joined: Tue Sep 22, 2015 10:05 am

Re: Timzone set from init.php

Post by terr3089 » Wed Aug 17, 2016 12:24 pm

Thanks for your reply. I've seen a lot of stuff about userdata without ever understanding how it is implemented until now.

It seems that userdata is used by a cloudformation template and only works when you launch a cluster (We are using an autoscaling group)

My issue is that once the system is up and running and then for whatever reason the cluster manager is rebooted then init.php resets the timezone to UTC and I can't see how to tell it to do otherwise.

My current workaround is to add a few lines to /etc/rc.local after the call to /root/zs-init/init.php

Code: Select all

WEB_API_KEY_HASH=`sqlite3 /usr/local/zend/var/db/gui.db "SELECT HASH FROM GUI_WEBAPI_KEYS WHERE NAME = 'administrator'"`
/usr/local/zend/bin/zs-manage store-directive -d date.timezone -v Europe/London  -N $WEB_API_KEY_NAME -K $WEB_API_KEY_HASH
sleep 5
/usr/local/zend/bin/zs-manage restart  -N $WEB_API_KEY_NAME -K $WEB_API_KEY_HASH 

Post Reply