mopa/remote-update-bundle

安装: 713

依赖者: 0

建议者: 0

安全: 0

星星: 3

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2012-07-24 17:58 UTC

This package is auto-updated.

Last update: 2024-09-19 10:27:43 UTC


README

此Bundle提供从命令行直接更新远程安装的命令。

app/console mopa:update:remote yourremote

安装

安装非常简单

步骤 1: 使用您的composer.json进行安装

{
    "require": {
        "mopa/remote-update-bundle": "dev-master",
    }
}

步骤 2: 在您的AppKernel.php中包含以下bundle

确保如果您已经使用它们,不要重复包含bundle。

// application/ApplicationKernel
public function registerBundles()
{
    return array(
        // ...
        new Mopa\Bundle\RemoteUpdateBundle\MopaRemoteUpdateBundle(),
        new Mopa\Bundle\WSSEAuthenticationBundle\MopaWSSEAuthenticationBundle(),
        new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(),
        new FOS\RestBundle\FOSRestBundle(),
        new JMS\SerializerBundle\JMSSerializerBundle($this)
        // ...
    );
}

步骤 2: 将必要的路由信息添加到您的routing.yml中

mopa_remote_update_bundle:
    type:     rest
    resource: "@MopaRemoteUpdateBundle/Resources/config/routing.yml"

步骤 3: 将必要的防火墙配置添加到您的security.yml中

为了保护API免受公众访问,我们需要一个防火墙和一个用户提供者

security:
    firewalls:
        wsse_secured:
            pattern:   ^/mopa/update/api/.*
            wsse:
                nonce_dir: null
                lifetime: 300
                provider: in_memory # the user provider providing you user with the role ROLE_REMOTE_UPDATER

如果您没有任何用户提供者或无法将ROLE_REMOTE_UPDATER添加到您的用户,请添加此内容

security:
    providers:
        in_memory:
            memory:
                users:
                    '%mopa_remote_update_user%':  { password: '%mopa_remote_update_password%', roles: 'ROLE_REMOTE_UPDATER' }

并在您的parameters.yml中

parameters:
    mopa_remote_update_url: http://yourhost
    mopa_remote_update_user: changethis
    mopa_remote_update_password: changethat

步骤 4: 在您的config.yml中添加必要的配置

在您的config.yml中导入必要的配置

imports:
    - { resource: @MopaRemoteUpdateBundle/Resources/config/config.yml }

如果您在项目中没有dbal连接,也包含sqlite配置

imports:
    - { resource: @MopaRemoteUpdateBundle/Resources/config/config.yml }
    - { resource: @MopaRemoteUpdateBundle/Resources/config/database.yml }

如果您不想在生产环境中使用此功能,只需将所有这些包含在config_dev.yml中即可,确保依赖项设置正确,同样适用于AppKernel和Bundles。

在您的config.yml中设置您的远程

mopa_remote_update:
    remotes:
        my_remote: # the alias to use on console, you can define as many remotes as you like
            url: %mopa_remote_update_url% # the url to your side might also be https
            username: %mopa_remote_update_user% # your username
            password: %mopa_remote_update_password% # your password
            preUpdate: git pull # optional: a command to run before composer updates the vendors, e.g. update your main application
            postUpdate: bin/post-composer.sh -w # optional: a command to run after composer updates
            updater: live # either live or cron see further down howto deal with cron
    composer: /usr/sbin/composer.phar # optional: sets the path to the composer binary if it cant be found

有一个有用的postUpdate打包程序,具有多个功能

bin/post-composer.sh -h

要获取描述

bin/envvars.default必须复制到bin/envvars并编辑,以使app/cache和app/logs可写,以便于web服务器。

步骤 5: 更新/创建模式

app/console doctrine:schema:update  --force

步骤 6(可选):配置cron更新器

如果您无法使用实时更新器,例如,因为您的web服务器没有权限更新供应商,您可以在远程机器上创建一个cronjob来执行更新

*/5   *   *   *  *    /path/to/your/app/console mopa:update:check # checks every 5 minutes if there is a new update job in queue

例如,为了记录输出以进行调试,您可以使用

*/5   *   *   *  *    /path/to/your/app/console mopa:update:check -v >> /path/to/your/app/logs/mopa_remote_update.log

步骤 7: 将您的更改提交到您最喜欢的vcs并设置您的远程。

现在是将相同内容推送到您的服务器的时间,并确保一切按预期工作。您还应该检查postUpdate命令和composer是否找到。

要测试更新,您可以使用

app/console mopa:update:local my_remote

步骤 8(可选):忽略MopaRemoteUpdateBundle bin文件

可选地将此添加到您的vcs忽略文件(例如 .gitignore)

# ignore MopaRemoteUpdateBundle bin files
bin/post-composer.sh
bin/envvars.default
app/Resources/remote_update.sqlite