YuJianghao / winwin-hexo-editor

An online hexo blog editor.
https://yujianghao.github.io/winwin-hexo-editor/
GNU General Public License v3.0
27 stars 8 forks source link

How to deploy service with custom server address, instead of localhost? #1

Closed LunaGao closed 4 years ago

LunaGao commented 4 years ago

image

I deploy this project to an aliyun service, and using domain, but it still connecting to localhost.

LunaGao commented 4 years ago

BTW, I click the login button, then show up the error. "Network error" image

YuJianghao commented 4 years ago

Sorry, for now the prebuild client can only use localhost.

You can build your own client follow this repo

  1. Download code and install dependences
git clone https://github.com/YuJianghao/winwin-hexo-editor-client
sudo npm install -g @quasar/cli
npm install
  1. Setup your server address
# inside hexo-editor-client/.env file
# you can change these values base on your server address
HEXO_SERVER_ROOT='http://yourapiserver.com:xxxx/'
  1. Bulid your dist files
quasar build
  1. Move your dist files from hexo-editor-client/dist/spa to hexo-editor/public
  2. Run npm start

If you have more questions, feel free to ask, I'll be online till night.

PS. Thank you for your star ~

YuJianghao commented 4 years ago

BTW, I click the login button, then show up the error. "Network error" image

It's the same reason.

The client is a stand alone spa. By default it will use http://localhost:5777/ as server address and use http://localhost:5777/token and http://localhost:5777/hexoeditorserver as auth and editor server address. Unless you build your own client with server address with your Aliyun address, the client will not work for now.

BTW if you have any idea about how to deploy the client to different addresses without rebuilding, I'm willing to change code!

LunaGao commented 4 years ago

Cool. I will try your solution.

YuJianghao commented 4 years ago

@LunaGao Remember to run git pull . I made some update after receiving your issue.

LunaGao commented 4 years ago

@LunaGao Remember to run git pull . I made some update after receiving your issue.

Awesome!!! So I just git pull and rebuild this project?

YuJianghao commented 4 years ago

@LunaGao Remember to run git pull . I made some update after receiving your issue.

Awesome!!! So I just git pull and rebuild this project?

Yes :p

Run git pull to update any repos you have cloned.

Build hexo-editor-client with Aliyun address correctly set.

Then deploy and try if it can work.

LunaGao commented 4 years ago

BTW, how can I stop this command?

npm run prd

Stop pm2 solution: https://pm2.keymetrics.io/docs/usage/process-management/

LunaGao commented 4 years ago

@LunaGao Remember to run git pull . I made some update after receiving your issue.

Awesome!!! So I just git pull and rebuild this project?

Yes :p

Run git pull to update any repos you have cloned.

Build hexo-editor-client with Aliyun address correctly set.

Then deploy and try if it can work.

I using

git pull
npm install
npm run start

It still failed with same issue.

YuJianghao commented 4 years ago

@LunaGao

Run pm2 list and you can see the process id at very left. Then run pm2 stop <process id> to stop. Also, pm2 restart <process id> to restart

Emm. It's just some updates about other features. Didn't fix this problem. You still need to clone hexo-editor-client and build it yourself. Guide are listed below. You need to set your Aliyun address to HEXO_SERVER_ROOT as the guide said.

https://github.com/YuJianghao/winwin-hexo-editor-client#use-as-a-stand-alone-web-app-with-winwinhexo-editor

LunaGao commented 4 years ago

@YuJianghao Failed when I running quasar build.

# quasar build

 Build mode........ spa
 Quasar theme...... mat
 Quasar CLI........ v0.17.26
 Quasar Framework.. v0.17.20
 Debugging......... no

 app:quasar-conf Reading quasar.conf.js +0ms
⚠️  Missing .babelrc file...
LunaGao commented 4 years ago

BTW, I install quasar-cli when I using quasar build command.

YuJianghao commented 4 years ago

@LunaGao Sorry my fault. You need to intsall quasar-cli by running sudo npm install -g @quasar/cli.

And it seems that I forgot to add highlight.js to dependences. So you also need to run npm i highlight.js at ./hexo-editor-client/. before running quasar build

LunaGao commented 4 years ago

Failed to install hightlight.js :(

# npm i hightlight.js
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/hightlight.js - Not found
npm ERR! 404 
npm ERR! 404  'hightlight.js@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-03-25T16_13_01_712Z-debug.log
YuJianghao commented 4 years ago

highlight.js :( typo always

LunaGao commented 4 years ago

Still same error.

root@maomishen:~/hexo-editor-client/winwin-hexo-editor-client# npm i highlight.js
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to https://registry.npmjs.org/highlight.js failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
+ highlight.js@9.18.1
added 1 package from 274 contributors in 16.474s

58 packages are looking for funding
  run `npm fund` for details

root@maomishen:~/hexo-editor-client/winwin-hexo-editor-client# quasar build

 Build mode........ spa
 Quasar theme...... mat
 Quasar CLI........ v0.17.26
 Quasar Framework.. v0.17.20
 Debugging......... no

 app:quasar-conf Reading quasar.conf.js +0ms
⚠️  Missing .babelrc file...

root@maomishen:~/hexo-editor-client/winwin-hexo-editor-client# npm install
up to date in 13.689s

58 packages are looking for funding
  run `npm fund` for details

root@maomishen:~/hexo-editor-client/winwin-hexo-editor-client# quasar build

 Build mode........ spa
 Quasar theme...... mat
 Quasar CLI........ v0.17.26
 Quasar Framework.. v0.17.20
 Debugging......... no

 app:quasar-conf Reading quasar.conf.js +0ms
⚠️  Missing .babelrc file...
YuJianghao commented 4 years ago

Have you uninstalled old version of quasar-cli by running sudo npm uninstall -g quasar-cli and reintsalled new version of quasar-cli by running sudo npm install -g @quasar/cli ?

It seem you are still using old quasar-cli

LunaGao commented 4 years ago

Is this my computer out of memory???

root@maomishen:~/hexo-editor-client/winwin-hexo-editor-client# quasar build

 Build mode........ spa
 Pkg quasar........ v1.9.10
 Pkg @quasar/app... v1.6.0
 Debugging......... no
 Publishing........ no

 app:extension Running "@quasar/dotenv" Quasar App Extension... +0ms
 app:quasar-conf Reading quasar.conf.js +7ms
 app:quasar-conf Extension(@quasar/dotenv): Extending quasar.conf... +3ms
 app:webpack Extending SPA Webpack config +5s
 app:artifacts Cleaned build artifact: "/root/hexo-editor-client/winwin-hexo-editor-client/dist/spa" +919ms
 app:generator Generating Webpack entry point +1ms
 app:build Building... +20ms

 SPA ██████████████████████    after hashing [88%]

<--- Last few GCs --->

[22061:0x63e4b00]    59285 ms: Scavenge 253.4 (256.5) -> 253.3 (257.2) MB, 4.5 / 0.0 ms  (average mu = 0.241, current mu = 0.202) allocation failure 
[22061:0x63e4b00]    60188 ms: Mark-sweep 253.8 (257.2) -> 253.5 (257.2) MB, 889.1 / 0.0 ms  (average mu = 0.129, current mu = 0.028) allocation failure scavenge might not succeed
[22061:0x63e4b00]    60856 ms: Mark-sweep 254.3 (257.5) -> 254.1 (257.7) MB, 657.3 / 0.0 ms  (average mu = 0.080, current mu = 0.016) allocation failure scavenge might not succeed

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x13de0d9]
    1: StubFrame [pc: 0x13def15]
Security context: 0x3e64f1340921 <JSObject>
    2: apply [0x3f4e2bece561] [/root/hexo-editor-client/winwin-hexo-editor-client/node_modules/webpack/lib/optimize/ConcatenatedModule.js:~1256] [pc=0xdbea1a2f96b](this=0x2b41b0f8e6d1 <HarmonyImportSpecifierDependencyConcatenatedTemplate map = 0x21d5ceb64c01>,0x1304add3a351 <Dependency map = 0x21d5ceb44901>,0x2960f9881111 <Source ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Writing Node.js report to file: report.20200326.003356.22061.0.001.json
Node.js report completed
 1: 0xa10730 node::Abort() [node]
 2: 0xa10b75 node::OnFatalError(char const*, char const*) [node]
 3: 0xb859ce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb85d49 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd34255  [node]
 6: 0xd348e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 7: 0xd43159 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xd43f95 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xd46a6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xd0d644 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
11: 0x105a93e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x13de0d9  [node]
Aborted
YuJianghao commented 4 years ago

If this is your Aliyun server, might be. It seems not error from hexo-client nor @quasar/cli. You can build it locally and upload to your server.

Thanks for the patience !!!!!

PS. Another way I just found might work.

In every files at ./public : replace every http://localhost:5777 with your server address like http://blabla.com

It's a temporary solution, but might work. Could you have a try? It work for me.

Thanks again!

LunaGao commented 4 years ago

Cool! I use "replace" solution. It working. Thanks for your help!