服务不可用将Vue应用程序运行到Linux上的Azure应用服务

时间:2017-12-28 23:58:32

标签: azure vue.js nuxt.js

我正在使用Linux上的Vue和Azure App Service开发Web应用程序。我已经能够在本地成功运行我的项目,但是当我在服务器上构建它时,它给了我一个服务不可用。

我正在使用NUXT,并且我将端口设置为3000(但我认为它需要是process.env.PORT)但我不确定如何设置它。

以下是我的日志:

2017-12-28 23:51:19.987 INFO  - Container logs
2017-12-28T23:47:30.262030070Z   _____                               
2017-12-28T23:47:30.262060870Z   /  _  \ __________ _________   ____  
2017-12-28T23:47:30.262065270Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
2017-12-28T23:47:30.262068270Z /    |    \/    /|  |  /|  | \/\  ___/ 
2017-12-28T23:47:30.262071070Z \____|__  /_____ \____/ |__|    \___  >
2017-12-28T23:47:30.262073970Z         \/      \/                  \/ 
2017-12-28T23:47:30.262076670Z A P P   S E R V I C E   O N   L I N U X
2017-12-28T23:47:30.262079070Z 
2017-12-28T23:47:30.262081470Z Documentation: http://aka.ms/webapp-linux
2017-12-28T23:47:30.262090570Z NodeJS quickstart: https://aka.ms/node-qs
2017-12-28T23:47:30.262093270Z 
2017-12-28T23:47:30.873698188Z Starting OpenBSD Secure Shell server: sshd.
2017-12-28T23:47:31.585835033Z Generating app startup command
2017-12-28T23:47:31.598205110Z Found scripts.start in package.json
2017-12-28T23:47:31.622921465Z Running npm start
2017-12-28T23:47:34.613812035Z 
2017-12-28T23:47:34.613840336Z > rapchat@1.0.0 start /home/site/wwwroot
2017-12-28T23:47:34.613844036Z > PORT=3000 nuxt build
2017-12-28T23:47:34.613846336Z 
2017-12-28T23:47:46.961289422Z 2017-12-28T23:47:46.943Z nuxt:build Building...
2017-12-28T23:47:55.010373380Z 2017-12-28T23:47:55.009Z nuxt:build App root: /home/site/wwwroot
2017-12-28T23:47:55.011085084Z 2017-12-28T23:47:55.010Z nuxt:build Generating /home/site/wwwroot/.nuxt files...
2017-12-28T23:47:55.285571198Z 2017-12-28T23:47:55.285Z nuxt:build Generating files...
2017-12-28T23:47:55.389093245Z 2017-12-28T23:47:55.388Z nuxt:build Generating routes...
2017-12-28T23:47:55.709850548Z 2017-12-28T23:47:55.709Z nuxt:build Building files...
2017-12-28T23:50:43.739654992Z Hash: [1m6564d52127cc0bc02817[39m[22m
2017-12-28T23:50:43.765815664Z Version: webpack [1m3.10.0[39m[22m
2017-12-28T23:50:43.765838664Z Time: [1m165962[39m[22mms
2017-12-28T23:50:43.765842564Z                                          [1mAsset[39m[22m       [1mSize[39m[22m  [1mChunks[39m[22m  [1m[39m[22m           [1m[39m[22m       [1mChunk Names[39m[22m
2017-12-28T23:50:43.765851664Z [1m[33mpages/yearinreview/_id.72cca8c6b7deec929d1d.js[39m[22m     [1m[33m489 kB[39m[22m       [1m3[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  pages/yearinreview/_id
2017-12-28T23:50:43.765856064Z                           [1m[32mimg/poly.83d4067.png[39m[22m    6.59 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765859664Z                        [1m[32mimg/text_me.e29d1a4.png[39m[22m    7.96 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765871364Z                    [1m[32mimg/google_play.ded200b.png[39m[22m    25.2 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765875264Z                      [1m[33mimg/footer_bg.a6a365d.png[39m[22m     [1m[33m738 kB[39m[22m        [1m[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  
2017-12-28T23:50:43.765879164Z                      [1m[32mimg/poly_gold.8915b42.png[39m[22m    3.24 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765882364Z                     [1m[32mimg/wavelength.3e69288.svg[39m[22m    15.1 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765885664Z        [1m[33mlayouts/default.2c425b8d20c7ccbabce7.js[39m[22m     [1m[33m607 kB[39m[22m       [1m0[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  layouts/default
2017-12-28T23:50:43.765889564Z            [1m[33mpages/beats.1be9d4d425bc4b070538.js[39m[22m     [1m[33m496 kB[39m[22m       [1m1[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  pages/beats
2017-12-28T23:50:43.765893364Z         [1m[33mpages/raps/_id.29b3e0119b309f2f6acb.js[39m[22m     [1m[33m522 kB[39m[22m       [1m2[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  pages/raps/_id
2017-12-28T23:50:43.765901764Z                      [1m[32mimg/app_store.4a95f44.png[39m[22m    20.2 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.765905364Z [1m[33mpages/rapnamegenerator.ff8cffdc140b77fa2ea4.js[39m[22m     [1m[33m490 kB[39m[22m       [1m4[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  pages/rapnamegenerator
2017-12-28T23:50:43.765909064Z          [1m[32mlayouts/blank.ebc2fbcfdb81050f1203.js[39m[22m    4.37 kB       [1m5[39m[22m  [1m[32m[emitted][39m[22m         layouts/blank
2017-12-28T23:50:43.765912464Z            [1m[32mpages/index.85eac62b3a21dec8f25c.js[39m[22m    10.5 kB       [1m6[39m[22m  [1m[32m[emitted][39m[22m         pages/index
2017-12-28T23:50:43.765915764Z            [1m[32mpages/terms.4a4ecf0382d8eab0cb90.js[39m[22m    4.66 kB       [1m7[39m[22m  [1m[32m[emitted][39m[22m         pages/terms
2017-12-28T23:50:43.765918964Z          [1m[32mpages/privacy.6d5f6e75849ee8948d68.js[39m[22m    7.63 kB       [1m8[39m[22m  [1m[32m[emitted][39m[22m         pages/privacy
2017-12-28T23:50:43.765975165Z           [1m[32mpages/_error.f68a2f2856029d9b54b5.js[39m[22m  607 bytes       [1m9[39m[22m  [1m[32m[emitted][39m[22m         pages/_error
2017-12-28T23:50:43.765981065Z                    [1m[33mapp.2ca9f8bb42c491af2573.js[39m[22m     [1m[33m447 kB[39m[22m      [1m10[39m[22m  [1m[32m[emitted][39m[22m  [1m[33m[big][39m[22m  app
2017-12-28T23:50:43.765984965Z                 [1m[32mcommon.02a832a1ad8a72340207.js[39m[22m     138 kB      [1m11[39m[22m  [1m[32m[emitted][39m[22m         common
2017-12-28T23:50:43.766833471Z               [1m[32mmanifest.6564d52127cc0bc02817.js[39m[22m    1.96 kB      [1m12[39m[22m  [1m[32m[emitted][39m[22m         manifest
2017-12-28T23:50:43.766839371Z                                       [1m[32mLICENSES[39m[22m    2.31 kB        [1m[39m[22m  [1m[32m[emitted][39m[22m         
2017-12-28T23:50:43.766842671Z  + 16 hidden assets
2017-12-28T23:50:43.766845071Z 
2017-12-28T23:50:43.766847471Z [1m[33mWARNING in asset size limit: The following asset(s) exceed the recommended size limit (300 kB).
2017-12-28T23:50:43.766850171Z This can impact web performance.
2017-12-28T23:50:43.766852671Z Assets: 
2017-12-28T23:50:43.766854971Z   img/footer_bg.a6a365d.png (738 kB)
2017-12-28T23:50:43.766857371Z   layouts/default.2c425b8d20c7ccbabce7.js (607 kB)
2017-12-28T23:50:43.766859771Z   pages/beats.1be9d4d425bc4b070538.js (496 kB)
2017-12-28T23:50:43.766862271Z   pages/raps/_id.29b3e0119b309f2f6acb.js (522 kB)
2017-12-28T23:50:43.766864671Z   pages/yearinreview/_id.72cca8c6b7deec929d1d.js (489 kB)
2017-12-28T23:50:43.766867071Z   pages/rapnamegenerator.ff8cffdc140b77fa2ea4.js (490 kB)
2017-12-28T23:50:43.766871071Z   app.2ca9f8bb42c491af2573.js (447 kB)[39m[22m

2017-12-28 23:51:19.988 ERROR - Container rapchat-website_2 for site rapchat-website did not start within expected time limit. Elapsed time = 230.0562799 sec
2017-12-28 23:51:23.303 INFO  - Starting container for site
2017-12-28 23:51:23.304 INFO  - docker run -d -p 23493:8080 --name rapchat-website_4 -e WEBSITE_NODE_DEFAULT_VERSION=6.11 -e APPSETTING_WEBSITE_NODE_DEFAULT_VERSION=6.11 -e WEBSITE_SITE_NAME=rapchat-website -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_INSTANCE_ID=fe0131188d0d8f5d73dcfe80d52622f03cc3e387d146b0ac5101928f37ee6535 -e HTTP_LOGGING_ENABLED=1 appsvc/node:6.11.5_1710252240  

提前致谢!!!

1 个答案:

答案 0 :(得分:0)

要托管我找到的一个Azure应用服务(无论如何在Windows上),您需要:

  • server.js文件
  • packages.config中的正确npm start任务。

<强> server.js

您可以使用的older basic version或新的1.x examples用于不同的节点服务器。您可以在这些中看到它们如何使用const port = process.env.PORT || 3000,其中process.env.PORT是Azure中默认设置的环境变量。

您可以在门户网站中为应用程序添加一个名为PORT的应用设置,以覆盖默认环境变量(如果您不得不这样做),但我不知道它是否有效,因为我在猜测Azure托管他们所知道的端口,信任并随意公开。

npm开始任务

node server.js,或尝试完全删除任务,因为Azure(至少在Windows上)会自动运行相同的任务。

自动部署 我还为我的应用程序设置了git部署,以便在我将提交推送到我的主分支时自动部署。我需要一个自定义的后期部署脚本来运行npm任务。如果有帮助,这里是my gist instructions。同样,对于Windows,您可以采用默认的部署后Linux脚本并添加必要的自定义行,就像我一样。