manpai

1632 经验值

我的定时任务里面写日志的话 创建的日志文件的用户组为root 了 导致laravel无法向日志文件里写日志,手动修改权限后才可以写 , 如果是laravel自己创建的日志文件自己可以写入。这个问题怎么解决啊??

<template>

    <!-- Page Sidebar -->
    <div class="page-sidebar" id="sidebar">
        <!-- Page Sidebar Header-->
        <div class="sidebar-header-wrapper">
            <input type="text" class="searchinput"/>
            <i class="searchicon fa fa-search"></i>

            <div class="searchhelper">搜索菜单</div>
        </div>
        <!-- /Page Sidebar Header -->
        <!-- Sidebar Menu -->
        <ul class="nav sidebar-menu">
            <li><a @click="setPageHeaderText('ddd')">sdfds</a></li>
            <router-link tag="li" v-for="menu in menus" :to="{ path: menu.text }">
                <a v-bind:class="{ 'menu-dropdown':menu.children }" @click="setPageHeaderText(menu.ext.display_name)">
                    <i class="menu-icon " v-bind:class=" menu.ext.icon "></i>
                    <span class="menu-text">   menu.ext.display_name   </span>
                    <i class="menu-expand" v-if="menu.children"></i>
                </a>

                <ul class="submenu" v-if="menu.children">
                    <router-link tag="li" v-for="submenu in menu.children" v-bind:class="'second'"
                                 :to="{ path: submenu.ext.name }"
                                 active-class="active">
                        <a @click="setPageHeaderText(submenu.ext.display_name)">
                            <span class="menu-text">  submenu.ext.display_name  </span>
                        </a>
                    </router-link>
                </ul>
            </router-link>

        </ul>
        <!-- /Sidebar Menu -->
    </div>
    <!-- /Page Sidebar -->

</template>
<style scoped>

</style>
<script>

    export default{
        name:'page-sidebar',

        computed:{
            menus(){
                return this.$store.state.menus
            }
        },
        methods: {
            setPageHeaderText(text){
                console.log(text)
                //动态设置page-header
                this.$store.dispatch('setPageHeaderText',text)
            }
        }
    }
</script>

如题vue2.0 在router-link 上面 的<li>sdfds</li> 这句可以执行 但下面ajax请求来的数据遍历的菜单上的事件不执行

<li><a @click="setPageHeaderText('hi')">dfds</a></li>
            <router-link tag="li" v-for="menu in menus" :to="{ path: menu.text }">

这个在v-for 之前的点击就会生效

现在问题又来了 现在我的菜单是AJAX请求过来的数据遍历后绑定的事件不生效 比如@click="setPageHeaderText(menu.ext.display_name)" 这样不生效 如果写在AJAX遍历前的这种事件就可以

<template>

    <!-- Page Sidebar -->
    <div class="page-sidebar" id="sidebar">
        <!-- Page Sidebar Header-->
        <div class="sidebar-header-wrapper">
            <input type="text" class="searchinput"/>
            <i class="searchicon fa fa-search"></i>

            <div class="searchhelper">搜索菜单</div>
        </div>
        <!-- /Page Sidebar Header -->
        <!-- Sidebar Menu -->
        <ul class="nav sidebar-menu">


            <router-link tag="li" v-for="menu in menus" :to="{ path: menu.text }">
                <a :class="{ 'menu-dropdown':menu.children }" :click="setPageHeaderText(menu.ext.display_name)">
                    <i class="menu-icon " :class=" menu.ext.icon "></i>
                    <span class="menu-text">   menu.ext.display_name   </span>
                    <i class="menu-expand" v-if="menu.children"></i>
                </a>

                <ul class="submenu" v-if="menu.children">
                    <router-link tag="li" v-for="submenu in menu.children" :class="'second'"
                                 :to="{ path: submenu.ext.name }"
                                 active-class="active">
                        <a :click="setPageHeaderText(submenu.ext.display_name)">
                            <span class="menu-text">  submenu.ext.display_name  </span>
                        </a>
                    </router-link>
                </ul>
            </router-link>

        </ul>
        <!-- /Sidebar Menu -->
    </div>
    <!-- /Page Sidebar -->

</template>
<style scoped>

</style>
<script>

    export default{
        name:'page-sidebar',
        data(){
            return{
                menus:[]
            }
        },

        methods: {
            setPageHeaderText(text){
            alert(text);
                //this.$store.dispatch('getPageHeaderText',text)
            }
        },
        mounted(){

            this.axios.get('menu').then(response => {
                const data = response.data.data

                if(data){
                for(var i=0;i<data.length;i++)
                   
                    if(data[i].children != null){
                        data[i].text='#'
                    }
                }
                this.menus = response.data.data
                setTimeout(InitiateSideMenu,1000)
               
            })
        }
    }

</script>

为什么我在v-for 的标签绑定事件 事件会自动执行 在遍历时我写的alert()会一直弹出我菜单里的不同的值 我的用意实际是 我在点这个菜单时 动态的更改 面包屑的值但一刷新页面就自动执行了

<template>

    <!-- Page Sidebar -->
    <div class="page-sidebar" id="sidebar">
        <!-- Page Sidebar Header-->
        <div class="sidebar-header-wrapper">
            <input type="text" class="searchinput"/>
            <i class="searchicon fa fa-search"></i>

            <div class="searchhelper">搜索菜单</div>
        </div>
        <!-- /Page Sidebar Header -->
        <!-- Sidebar Menu -->
        <ul class="nav sidebar-menu">


            <router-link tag="li" v-for="menu in menus" :to="{ path: menu.text }">
                <a :class="{ 'menu-dropdown':menu.children }" :click="setPageHeaderText(menu.ext.display_name)">
                    <i class="menu-icon " :class=" menu.ext.icon "></i>
                    <span class="menu-text"> { menu.ext.display_name } </span>
                    <i class="menu-expand" v-if="menu.children"></i>
                </a>

                <ul class="submenu" v-if="menu.children">
                    <router-link tag="li" v-for="submenu in menu.children" :class="'second'"
                                 :to="{ path: submenu.ext.name }"
                                 active-class="active">
                        <a :click="setPageHeaderText(submenu.ext.display_name)">
                            <span class="menu-text">{ submenu.ext.display_name }</span>
                        </a>
                    </router-link>
                </ul>
            </router-link>

        </ul>
        <!-- /Sidebar Menu -->
    </div>
    <!-- /Page Sidebar -->

</template>
<style scoped>

</style>
<script>

    export default{
        name:'page-sidebar',
        data(){
            return{
                menus:[]
            }
        },

        methods: {
            setPageHeaderText(text){
            alert(text);
                //this.$store.dispatch('getPageHeaderText',text)
            }
        },
        mounted(){

            this.axios.get('menu').then(response => {
                const data = response.data.data

                if(data){
                for(var i=0;i<data.length;i++)
                   
                    if(data[i].children != null){
                        data[i].text='#'
                    }
                }
                this.menus = response.data.data
                setTimeout(InitiateSideMenu,1000)
               
            })
        }
    }

</script>

为什么我在v-for 的标签绑定事件 事件会自动执行? 我写的alert()会一直弹出值

好久有空录个 小程序的教程系列嘛 相信这个会很火

如果想在菜单上加权限控制怎么做呢?想要根据不同的权限展示菜单

想到了 可以动态地控制 add方法

今天找到了问题 我想应该是BUG吧

public function getDumpCommand(string $dumpFile, string $temporaryCredentialsFile): string
    {
        $this->setDumpBinaryPath(config('database.connections.mysql.dump.dump_command_path')); //这是我加上的 。

执行这句就可以备份成功了setDumpBinaryPath 这个方法在它的包里没有任务地方调用。为什么会这样,
这只是可以临时解决 如果包一量升级 代码又会被覆盖,唉 ,怎么根本解决掉

难道要克隆一个包自己改一下?以适合自身的环境

线上和本地都一样的问题 系统是centos 7 lnmp

[root@iZ23rnsy0l5Z smt_business]# which php
/usr/local/php/bin/php
[root@iZ23rnsy0l5Z smt_business]# which mysqldump
/usr/local/mysql/bin/mysqldump

[root@iZ23rnsy0l5Z smt_business]# echo $PATH
/usr/local/nginx/sbin:/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

mysql 配置

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => 'my_',
            'strict' => true,
            'engine' => null,
            'dump' => [
                'dump_command_path' => '/usr/local/mysql/bin', // only the path, so without `mysqldump` or `pg_dump`
                'use_single_transaction',
                'timeout' => 60,
                'exclude_tables' => [],
                'add_extra_option' => '--extended-insert=FALSE --complete-insert=TRUE',
            ],
        ],

这是备份的配置文件

<?php

return [

    'backup' => [

        /*
         * The name of this application. You can use this name to monitor
         * the backups.
         */
        'name' => env('APP_URL'),

        'source' => [

            'files' => [

                /*
                 * The list of directories and files that will be included in the backup.
                 */
                'include' => [
                    base_path(),
                ],

                /*
                 * These directories and files will be excluded from the backup.
                 *
                 * Directories used by the backup process will automatically be excluded.
                 */
                'exclude' => [
                    base_path('vendor'),
                    base_path('node_modules'),
                ],

                /*
                 * Determines if symlinks should be followed.
                 */
                'followLinks' => false,
            ],

            /*
             * The names of the connections to the databases that should be backed up
             * Only MySQL and PostgreSQL databases are supported.
             */
            'databases' => [
                'mysql',
                'pgsql',
            ],
        ],

        'destination' => [

            /*
             * The filename prefix used for the backup zip file.
             */
            'filename_prefix' => '',

            /*
             * The disk names on which the backups will be stored.
             */
            'disks' => [
                'local',
            ],
        ],
    ],


    /*
     * You can get notified when specific events occur. Out of the box you can use 'mail' and 'slack'.
     * For Slack you need to install guzzlehttp/guzzle.
     *
     * You can also use your own notification classes, just make sure the class is named after one of
     * the `Spatie\Backup\Events` classes.
     */
    'notifications' => [

        'notifications' => [
            \Spatie\Backup\Notifications\Notifications\BackupHasFailed::class         => ['mail'],
            \Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFound::class => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupHasFailed::class        => ['mail'],
            \Spatie\Backup\Notifications\Notifications\BackupWasSuccessful::class     => ['mail'],
            \Spatie\Backup\Notifications\Notifications\HealthyBackupWasFound::class   => ['mail'],
            \Spatie\Backup\Notifications\Notifications\CleanupWasSuccessful::class    => ['mail'],
        ],

        /*
         * Here you can specify the notifiable to which the notifications should be sent. The default
         * notifiable will use the variables specified in this config file.
         */
        'notifiable' => \Spatie\Backup\Notifications\Notifiable::class,

        'mail' => [
            'to' => '[email protected]',
        ],

        'slack' => [
            'webhook_url' => '',
        ],
    ],

    /*
     * Here you can specify which backups should be monitored.
     * If a backup does not meet the specified requirements the
     * UnHealthyBackupWasFound event will be fired.
     */
    'monitorBackups' => [
        [
            'name' => env('APP_URL'),
            'disks' => ['local'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],

        /*
        [
            'name' => 'name of the second app',
            'disks' => ['local', 's3'],
            'newestBackupsShouldNotBeOlderThanDays' => 1,
            'storageUsedMayNotBeHigherThanMegabytes' => 5000,
        ],
        */
    ],


    'cleanup' => [
        /*
         * The strategy that will be used to cleanup old backups. The default strategy
         * will keep all backups for a certain amount of days. After that period only
         * a daily backup will be kept. After that period only weekly backups will
         * be kept and so on.
         *
         * No matter how you configure it the default strategy will never
         * delete the newest backup.
         */
        'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,

        'defaultStrategy' => [

            /*
             * The number of days for which backups must be kept.
             */
            'keepAllBackupsForDays' => 7,

            /*
             * The number of days for which daily backups must be kept.
             */
            'keepDailyBackupsForDays' => 16,

            /*
             * The number of weeks for which one weekly backup must be kept.
             */
            'keepWeeklyBackupsForWeeks' => 8,

            /*
             * The number of months for which one monthly backup must be kept.
             */
            'keepMonthlyBackupsForMonths' => 4,

            /*
             * The number of years for which one yearly backup must be kept.
             */
            'keepYearlyBackupsForYears' => 2,

            /*
             * After cleaning up the backups remove the oldest backup until
             * this amount of megabytes has been reached.
             */
            'deleteOldestBackupsWhenUsingMoreMegabytesThan' => 5000,
        ],
    ],
];

mysql,pgsql 在用php artisan backup:run 都可以备份

* * * * * /usr/local/php/bin/php /workspace/dev1/smt_business/artisan schedule:run >> /dev/null 2>&1

踩坑的来了 加上php 路径后到是可以运行了,但是又报 mysqldump 找不到了 路径是填写对了的服务器上路径/usr/local/mysql/bin/mysqldump, 配置填的/usr/local/mysql/bin/ 手动可以备份 现在定时发邮件里面报找不到命令了

[root@iZ23rnsy0l5Z smt_business]# php artisan backup:run

Starting backup...

Dumping database smt_manufacturer...

Dumping database smtapp_location...

Determining files to backup...

Zipping 1174 files...

Created zip containing 1174 files. Size is 15.51 MB

Copying zip to disk named local...

Successfully copied zip to disk named local.

Backup completed!

这是手动执行可以备份成功

下面这是邮箱发送的报错信息

Whoops!

Important: An error occurred while backing up `Laravel`

Exception message: `The dump process failed with exitcode 127 : Command not found : sh: mysqldump: command not found `

Exception trace: `#0 /data/wwwroot/smt_business/vendor/spatie/db-dumper/src/DbDumper.php(222): Spatie\DbDumper\Exceptions\DumpFailed::processDidNotEndSuccessfully(Object(Symfony\Component\Process\Process)) #1 /data/wwwroot/smt_business/vendor/spatie/db-dumper/src/Databases/MySql.php(88): Spatie\DbDumper\DbDumper->checkIfDumpWasSuccessFul(Object(Symfony\Component\Process\Process), '/data/wwwroot/s...') #2 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(200): Spatie\DbDumper\Databases\MySql->dumpToFile('/data/wwwroot/s...') #3 [internal function]: Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup\{closure}(Object(Spatie\DbDumper\Databases\MySql), 0) #4 /data/wwwroot/smt_business/vendor/laravel/framework/src/Illuminate/Support/Collection.php(603): array_map(Object(Closure), Array, Array) #5 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(203): Illuminate\Support\Collection->map(Object(Closure)) #6 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(133): Spatie\Backup\Tasks\Backup\BackupJob->dumpDatabases('/data/wwwroot/s...') #7 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(113): Spatie\Backup\Tasks\Backup\BackupJob->createBackupManifest() #8 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(43): Spatie\Backup\Tasks\Backup\BackupJob->run() #9 [internal function]: Spatie\Backup\Commands\BackupCommand->handle() #10 /data/wwwroot/smt_business/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array) #11 /data/wwwroot/smt_business/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array) #12 /data/wwwroot/smt_business/vendor/symfony/console/Command/Command.php(254): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #13 /data/wwwroot/smt_business/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #14 /data/wwwroot/smt_business/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(22): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /data/wwwroot/smt_business/vendor/symfony/console/Application.php(820): Spatie\Backup\Commands\BaseCommand->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /data/wwwroot/smt_business/vendor/symfony/console/Application.php(187): Symfony\Component\Console\Application->doRunCommand(Object(Spatie\Backup\Commands\BackupCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #17 /data/wwwroot/smt_business/vendor/symfony/console/Application.php(118): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 /data/wwwroot/smt_business/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #19 /data/wwwroot/smt_business/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 {main}