问题描述
PHP的Web Job,通过artisan来配置路径启动PHP任务,相关启动脚本如下:
artisan_path = "d:\\home\\site\\wwwroot"; cd ${artisan_path} echo "\n" pwd php artisan schedule:run
但是,在运行的时候遇见报错:
[07/06/2023 01:57:31 > 0f21a2: INFO] /d/home/site/wwwroot [07/06/2023 01:57:32 > 0f21a2: ERR ] '\\10.0.176.8\volume-30-default\532b2b267e7c072\a7d3f0082847394a45e5733bdeceafa2488ae\site\wwwroot' [07/06/2023 01:57:32 > 0f21a2: ERR ] CMD.EXE was started with the above path as the current directory. [07/06/2023 01:57:32 > 0f21a2: ERR ] UNC paths are not supported. Defaulting to Windows directory. [07/06/2023 01:57:33 > 0f21a2: INFO] No scheduled commands are ready to run.
问题解答
报错为UNC Paths不支持,所以最开始的解决办法就是把 artisan 的路径配置写为默认的 “ d:\home\site\wwwroot\artisa ” 全路径作为临时方案来解决问题。
另一种不用修改 artisan 配置代码的方案是为 App Service增加一个 MSYS 配置,设置值为: nonativeinnerlinks。
参考资料
PHP artisan: Artisan是Laravel中自带的命令行工具的名称。它提供了一些开发过程中有用的命令用。它是基于强大的Symfony Console 组件开发的。https://docs.golaravel.com/docs/4.0/artisan
UNC paths:Universal Naming Convention。格式:\servername\sharename,其中servername是服务器名。sharename是共享资源的名称。 https://learn.microsoft.com/en-us/answers/questions/1167298/kudu-deployment-script-throws-unc-path-error?page=1
MSYS : Minimal GNU(POSIX)system on Windows,是一个小型的GNU环境,包括基本的bash,make等等。是Windows下最优秀的GNU环境 https://github.com/msys2/msys2.github.io/issues/152