Yanting Lin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee
  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Wherehows Build Code with Windows Date: 2017/11/27 ## 前置作業 請優先參考 [官網](https://github.com/linkedin/WhereHows/blob/master/wherehows-docs/getting-started.md) 1. java sdk 1.8 2. 安裝 docker, docker-compose 3. git bash for windows 4. 設定JAVA_HOME的環境變數 5. 設定HADOOP_HOME的環境變數 6. 確認網路環境是否不會限制存取特定網域資訊 7. (Optional) 建議不要在已經下載好的模組下 rebuild module,不適用於此case 8. (Optional) 盡可能不要在本機也裝不同版本的 nodejs,有時候會有問題 9. (Better) 給予Docker Default VM 4GB RAM以上的空間 ### 設定環境變數 1. JAVA_HOME (1). Wherehows要用java 1.8 build, 設定方式如下 ![](https://i.imgur.com/FMwVKYw.png) (2). (Optional) 若已經build test failed,要先清除因test fail產生但未清除的測試檔案 目錄應是: /c/Users/<USER-NAME>/AppData/Local/Temp/ ![](https://i.imgur.com/iDP8j30.png) 若裡面沒有但是還是在common-test fail 可參考[這裡](https://hackmd.io/KYMwLAHMlgtARgVnvWYBsYAmsLYEywDsAnAMwkjoAM1AhhPCUA==#2-build-test-fail的原因),修改程式以顯示temp***.job的所在路徑 清除指令 : `rm temp*.job` 2. HADOOP_HOME and system path (Windows Only) 參考[此篇](https://stackoverflow.com/questions/19620642/failed-to-locate-the-winutils-binary-in-the-hadoop-binary-path)下載指定[檔案](https://github.com/srccodes/hadoop-common-2.2.0-bin/archive/master.zip)解壓縮到任意目錄後,環境變數設定方式如下 (1). 設定使用者的環境變數 **HADOOP_HOME = <PATH-TO>\hadoop-common-2.2.0-bin-master** ![](https://i.imgur.com/eAdfZun.png) (2). 在系統path加上 **${HADOOP_HOME}\bin** ![](https://i.imgur.com/U0ntaYp.png) :::warning 若不設定, `./gradlew build` 會失敗 可用 `./gradlew build -x test` 跳過但不建議 ::: ## Build code 方式 一般權限開啟 git bash 即可 1. 於 Project根目錄 WhereHows/ , 輸入以下指令 ```shell ./gradlew build ``` 2. (推薦) WhereHows/wherehows-docker/ , 輸入以下指令 ```shell # ./build.sh <image-version> ./build.sh 1 # if success docker-compose up ``` ## Build fail Root Cause file @ wherehows-web/ :::danger node_modules/broccoli-eyeglass/lib/broccoli_sass_compiler.js ::: Windows 無法順利build code的問題摘要: * wherehows-web 中的 Ember build failed * Error Log https://github.com/linkedin/WhereHows/issues/855 ### 問題描述   sass-eyeglass/broccoli-eyeglass 模組尚未處理windows路徑, 加上nodejs對不同作業系統有各自處理路徑的機制。因此: 1. 直接給windows路徑會無法正確讀取檔案。 ::: info 需修改 scopedFileName & filesInTree function。 ::: 2. 沒特別將來源的css檔案路徑切分css根目錄 (例如: app/styles/),導致會在wherehows-web/dist/assets/ 產生包含css根目錄的css file (例如: dist/assets/app/styles/),因此網頁會找不到應該在預設目錄下(assets/)的wherehows-web-FINGERPINRT.css。 ::: info 需修改 parsePath function,針對windows os特別處理 ::: :::warning 注意: 這是針對emberApp做的修改,其他framework要再看看 ::: broccoli_sass_compiler.js 的 [原始碼](https://github.com/sass-eyeglass/broccoli-eyeglass/blob/master/lib/broccoli_sass_compiler.js) ### Fast-solution 可參考自行修改的範例檔案 (last updated: 2017/11/28): 1. [broccoli_sass_compiler.js](https://drive.google.com/open?id=1iBSTN0AH3cKttuWGzA66MzrjwAVEsN4V) 解壓縮到 WhereHows/wherehows-web/ 2. [ember.gradle](https://drive.google.com/open?id=16ScDQMDwaqCQgctOvLtAzff58iw_aHcc) 覆蓋掉 WhereHows/gradle/scripts/ ### Detail Solution *由於node_module會在yarnInstall與emberInstall時才開始下載模組,需在intstall後覆蓋 (1). 修改以下程式碼,並把修改好的broccoli_sass_compiler.js 放在 WhereHows/wherehows-web/<PATH-TO>/ folder **broccoli_sass_compiler.js** ``` javascript // Support for older versions of node. function parsePath(pathname) { if (os.platform() === 'win32') { /* Remove emberApp default css's root folder. In linux, before first '/' would be regard as root folder, implies app/styles will be root folder after path.parse In windows, root folder always is C:\\, therefore app\\styles is dir folder not root folder however, 'app\\styles' logically regarded as css's root in emberApp */ pathname = pathname.replace("app\\styles","") } /* 省略 */ } /* 省略 */ module.exports = class BroccoliSassCompiler extends BroccoliPlugin { /* 省略 */ scopedFileName(file) { file = this.relativize(file); if (this.treeName) { return path.join(this.treeName, file); } else { return file; } } /* 省略 */ filesInTree(srcPath) { let sassDir = this.sassDir || ""; let files = []; if (this.discover) { let pattern = path.join(srcPath, sassDir, "**", "[^_]*.scss"); files = glob.sync(pattern); } this.sourceFiles.forEach(sourceFile => { let pattern = path.join(srcPath, sassDir, sourceFile); files = files.concat(glob.sync(pattern)); }); files = files.map(function(rawPath){ return path.normalize(rawPath); }); return unique(files); } /* 省略 */ ``` (2). 在 WhereHows/gradle/scripts/ 修改 ember.gradle **ember.gradle** ```groovy /* 省略 */ task emberBuild(type: NodeTask, dependsOn: bowerInstall) { doFirst { copy { // Copy the output of copyTask from '<PATH-TO>/broccoli_sass_compiler.js' into 'node_modules/broccoli-eyeglass/lib' } } script = file('node_modules/ember-cli/bin/ember') args = ['build', '--environment', 'production'] } /* 省略 */ ``` 完成之後,確認沒有權限問題即可build ## Develop with intellij IDEA 1. WhereHows/ 輸入以下指令: ``` ./gradlew idea ``` 2. open -> WhereHows 目錄打開即可,**建議不要選擇 gradle.build** 若照[官網的建議](https://github.com/linkedin/WhereHows/blob/master/wherehows-docs/getting-started.md#edit-the-source-code-in-your-ide)選完之後,會有一些選項,一打開他就是無條件先gradle.build一番,但用intellij的gradle build目前會有問題。 Note: 不要用intellij的 gradle wrapper,也不在那build ## Docker in new git bash windows 1. `docker-machine start` (如果Docker那台VM還沒開) 2. `docker-machine env` 3. 把env輸出結果要求你複製貼上的貼上 e.g., 我的是 ` eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)` 4. 在Wherehows-docker目錄下,下 `docker-compose up` ## Docker elasticsearch memory too low 如果Elasticsearch開啟時會有 vm.max_map_count [65530] too low的問題 透過 `docker-machine ssh default` 指令進入docker-machine後,輸入以下指令 : ``` sudo sysctl -w vm.max_map_count=262144 ``` ## Change docker machine location 參考[這裡](https://stackoverflow.com/questions/33933107/change-docker-machine-location-windows/33934211?noredirect=1)新增兩個環境變數 `MACHINE_STORAGE_PATH`、`DOCKER_CERT_PATH`,指向欲使用的目錄 ![](https://i.imgur.com/xNtCcYO.png =350x388)![](https://i.imgur.com/785TxYf.png =350x388) :::info 做任何環境變數的修改,記得bash要重開 ::: ## Customized docker machine size :::danger 以下操作,用Kitematic開啟時,可能會自動移除重建default vm Toolbox的Kitematic 已被Docker官方列為Deprecated,因此建議以git bash操作為主 ::: 參考[Kitematic官方建議](https://github.com/docker/kitematic/wiki/Common-Issues-and-Fixes#running-out-of-space) 使用 `--virtualbox-disk-size` 參數來指定VM大小,單位是MB。以100GB空間為例: ``` docker-machine create -d virtualbox --virtualbox-disk-size "100000" default ``` *記憶體 --virtualbox-memory "4096" 忘記設定,在Virtualbox可以修改 ## Others about Docker 1. Mysql 開啟速度過慢: 若電腦運算效能不佳或記憶體不足可能會發生 等到Mysql完全開啟後,再重啟Frontend跟Backend 2. 從容器拿出檔案 or 複製檔案至容器 (資料夾亦可) ```shell # docker cp <container_name>:<absolute_path> <your_path> docker cp wherehowsdocker_wherehows-backend_1:/application/logs/etl/foo.txt . # docker cp <your_path> <container_name>:<absolute_path> docker cp foo.txt wherehowsdocker_wherehows-backend_1:/application/logs/etl/ ``` 3. "Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows" : 重新到[官網](https://docs.docker.com/toolbox/toolbox_install_windows/)下載Toolbox安裝更新即可 4. Docker Toolbox 是給 Win 10 標準版以前的Windows OS使用 5. [Docker Community Edition for Windows](https://store.docker.com/editions/community/docker-ce-desktop-windows) 是給Win10 企業版以上的使用 6. [Toolbox的Kitematic is deprecated](https://github.com/docker/kitematic/issues/2817) , toolbox的Kitematic不建議使用 官方目前建議用 [Docker for Mac](https://docs.docker.com/docker-for-mac/) or [Docker for Windows](https://docs.docker.com/docker-for-windows/) 7. 清除Untouched的volume `docker volume rm $(docker volume ls -qf dangling=true)` ## References 1. [Using path.normalize and path.sep to overcome windows issues](https://github.com/sass-eyeglass/broccoli-eyeglass/pull/38) 2. [Nodejs path](https://nodejs.org/api/path.html#path_path_normalize_path) 3. [Detail solution](https://hackmd.io/KYVgzGAsBGAmwFoDGBDEIGRUsCAcSW+AjLGMYdgOyTFA?both#detail-solution) 的 Github issue [討論串](https://github.com/sass-eyeglass/broccoli-eyeglass/issues/37) 4. [Path issue with different os](https://shapeshed.com/writing-cross-platform-node/)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully