def install_app():
    """ Performs application installation
    """

    hookenv.log('Installing Dokuwiki', 'info')

    # Configure NGINX vhost
    nginx.configure_site('default', 'vhost.conf',
                         listen_address=php.socket())

    # Update application
    dokuwiki.download_archive()

    # Needs to set dokuwiki directory permissions for installation
    app_path = nginx.get_app_path()

    render(source='local.php',
           target=path.join(app_path, 'conf/local.php'),
           context=config, perms=0o644)

    render(source='acl.auth.php',
           target=path.join(app_path, 'conf/acl.auth.php'),
           context=config, perms=0o644)

    render(source='plugins.local.php',
           target=path.join(app_path, 'conf/plugins.local.php'),
           context=config, perms=0o644)

    # Clean up install.php as we don't need it
    call("rm -f {}/conf/install.php", shell=True)

    php.restart()
    service_restart('nginx')
    hookenv.status_set('active', 'Dokuwiki is installed!')
示例#2
0
def enable_stats(stats):
    cfg = {
        'pm.status_path': '/php-status',
        'ping.path': '/php-ping',
        'ping.response': 'pong',
    }

    restart = php.configure(cfg)
    set_state('php.configured')

    if restart:
        php.restart()

    stats.configure(7777, cfg['pm.status_path'], cfg['ping.path'],
                    cfg['ping.response'])
def config_changed():

    if not is_state('nginx.available'):
        return

    # Define user
    app_path = nginx.get_app_path()
    render(source='users.auth.php',
           target=path.join(app_path, 'conf/users.auth.php'),
           context=config, perms=0o664)
    call('chown www-data:www-data -R {}'.format(app_path), shell=True)
    call('chmod 775 -R {}/conf'.format(app_path), shell=True)
    call('mkdir -p {app_path}/data && chmod 775 -R {app_path}/data'.format(
        app_path=app_path), shell=True)

    php.restart()
    service_restart('nginx')
    hookenv.status_set('active', 'Ready')
示例#4
0
def configure():
    cfg_map = {
        'php-max-children': 'pm.max_children',
        'php-start-servers': 'pm.start_servers',
        'php-min-spare-servers': 'pm.min_spare_servers',
        'php-max-spare-servers': 'pm.max_spare_servers',
        'php-max-requests': 'pm.max_requests',
    }

    c = config()
    php_cfg = {cfg_map[k]: v for k, v in c.items() if k in cfg_map}
    php_cfg['listen'] = '127.0.0.1:7777'

    # Only restart php-fpm if we changed configuration
    restart = php.configure(php_cfg)
    set_state('php.configured')

    if restart:
        php.restart()

    set_state('php.ready')
示例#5
0
 def test_restart(self, mv, msr):
     mv.return_value = ['9', '99']
     php.restart()
     msr.assert_called_with('bin-exec')