sh laravel主管

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh laravel主管相关的知识,希望对你有一定的参考价值。


# install-laravel-supervisor

```shell
sudo cp install-laravel-supervisor.sh /usr/local/bin/lsp
sudo chmod +x /usr/local/bin/lsp
```

在 `laravel` 项目跟目录 执行:
```shell
sudo lsp [work-name]
```
#!/bin/bash

# Author: Jaeger <JaegerCode@gmail.com>

fileName=$1;
# CentOS下目录改为:/etc/supervisord.d
confBasePath="/etc/supervisor/conf.d/"
# CentOS下文件后缀改为:.ini
confPath=${confBasePath}"$fileName.conf"

function add()
{
	laravelPath=`pwd`;

	echo 'check supervisor...'
	#type supervisorctl > /dev/null || (sudo apt update && sudo apt install supervisor -y)

	conf="[program:$fileName]	\nprocess_name=%(program_name)s_%(process_num)02d	\ncommand=php $laravelPath/artisan queue:work --sleep=3 --tries=3	\nautostart=true	\nautorestart=true	\nuser=nobody	\nnumprocs=2	\nredirect_stderr=true	\nstdout_logfile=$laravelPath/storage/logs/worker.log"
		
	echo "out conf:$confPath"
	sudo echo -e $conf>$confPath;

	echo 'start work....'
	sudo supervisorctl reread
	sudo supervisorctl update
	sudo supervisorctl start $fileName:*
	status
}

function delete()
{
	echo "delete:$confPath"
	sudo supervisorctl stop $fileName:*
	sudo rm $confPath;
	sudo supervisorctl reread
	sudo supervisorctl update
	status
}

function list()
{
	path=$confBasePath
	cd $path
	echo -e "\n"
	for filename in `ls`
	do
		echo $(basename $filename .conf) 
	done
	echo -e "\n"
}

function status()
{
	echo -e "\n ----------run status---------- \n"
	sudo  supervisorctl status
	echo -e "\n"
}

function restart()
{
	sudo supervisorctl restart $fileName:*
}

function option()
{
	echo "选择操作:"
    select selected in '列出conf' '添加conf' '删除conf' '运行状态' '重启任务' '退出';do
        case $selected in
        	'列出conf')
				list
				break
				;;
            '添加conf')
                add
                break
                ;;
            '删除conf')
                delete
                break
                ;;
            '运行状态')
                status
                break
                ;;
            '重启任务')
                restart
                break
                ;;
            '退出')exit;;
        esac
    done;
    option;
}

option

以上是关于sh laravel主管的主要内容,如果未能解决你的问题,请参考以下文章

sh laravel主管

text CentOS的Laravel主管

laravel 8 应用程序共享主机的主管替代方案

何时在 Laravel Horizo​​n 中使用多个主管

sh nab蜘蛛的主管conf

无法获得工匠队列:在 Elastic Beanstalk (Laravel/Redis) 上使用主管处理作业