问:
heroku deploy error (remote rejected) master -> master (pre-receive hook declined
(additional error)

```<code>PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku open
PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku logs --tail
2019-05-31T16:45:02.171005+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:02.171116+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:02.171314+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.171426+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:02.171546+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.179317+00:00 app[web.1]:
2019-05-31T16:45:02.179463+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.179533+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_172Z-debug.log
2019-05-31T16:45:02.185867+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:02.186262+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:02.187262+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:02.187389+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:02.187579+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.187687+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:02.187797+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.193111+00:00 app[web.1]:
2019-05-31T16:45:02.193255+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.193337+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_188Z-debug.log
2019-05-31T16:45:02.258650+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:02.266584+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:45:02.249741+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:45:07.723357+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:45:09.873974+00:00 app[web.1]:
2019-05-31T16:45:09.874005+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:45:09.874008+00:00 app[web.1]: > npm run build
2019-05-31T16:45:09.874009+00:00 app[web.1]:
2019-05-31T16:45:10.385932+00:00 app[web.1]:
2019-05-31T16:45:10.385960+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:45:10.385962+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:45:10.385964+00:00 app[web.1]:
2019-05-31T16:45:10.396373+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:45:10.403250+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:45:10.403532+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.403769+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:45:10.404003+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:45:10.405101+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:10.405275+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:10.405526+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.405698+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:10.405864+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.413990+00:00 app[web.1]:
2019-05-31T16:45:10.414188+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.414314+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_407Z-debug.log
2019-05-31T16:45:10.442078+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.445480+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:10.451107+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:10.451370+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:10.451711+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.453601+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:10.456332+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.466855+00:00 app[web.1]:
2019-05-31T16:45:10.467160+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.467324+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_460Z-debug.log
2019-05-31T16:45:10.550003+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:10.537734+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:23.749632+00:00 app[api]: Set PORT, MONGO_URL_PROD, MONGO_URL, COOKIE_SECRET, AWS_KEY, AWS_PW config vars by user hbh4231@gmail.com
2019-05-31T16:47:23.749632+00:00 app[api]: Release v4 created by user hbh4231@gmail.com
2019-05-31T16:47:24.905228+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:47:29.835194+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:47:32.064545+00:00 app[web.1]:
2019-05-31T16:47:32.064571+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:47:32.064573+00:00 app[web.1]: > npm run build
2019-05-31T16:47:32.064575+00:00 app[web.1]:
2019-05-31T16:47:32.469293+00:00 app[web.1]:
2019-05-31T16:47:32.469338+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:47:32.469341+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:47:32.469343+00:00 app[web.1]:
2019-05-31T16:47:32.475344+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:47:32.479177+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:47:32.479507+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.479713+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:47:32.479949+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:47:32.481275+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:47:32.481386+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:47:32.481567+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.481732+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:47:32.481842+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.490356+00:00 app[web.1]:
2019-05-31T16:47:32.490515+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.490598+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_483Z-debug.log
2019-05-31T16:47:32.497599+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.498150+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:47:32.499418+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:47:32.499643+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:47:32.499909+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.500099+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:47:32.500279+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.507354+00:00 app[web.1]:
2019-05-31T16:47:32.507595+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.507739+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_501Z-debug.log
2019-05-31T16:47:32.574723+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:47:32.562071+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:54.648467+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=648f1dcd-fd24-4008-9316-9c5064c48981 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:47:55.002820+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=9e0aef22-1945-4863-843d-c9b06395c19c fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.197785+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=4498ed4d-0722-42bd-b3a9-a1cdccd2808e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.601213+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=8e23955e-771d-42a1-a381-239137799a1e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.440580+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=e33dde27-d710-45c8-ae47-88a211109e87 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.799842+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=2b7bde17-2418-44e4-baaf-8ceb38f61381 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.019477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=5bf7c128-f282-4ceb-8f31-2aac4e3588ec fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.410926+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=88024c5c-027d-49e3-ba51-14b556f3a3fe fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
</code>```

I am beginner and want to deploy express app using heroku but error has occured.

First I enter commend heroku create and it works. but next when I enter git push heroku master, error happened. I will add my package.json and error log.

error point is `git push heroku master

this is package.json:

```<code>{
  "name": "utube",
  "version": "1.0.0",
  "description": "clone youtube",
  "scripts": {
    "dev:server": "nodemon --exec babel-node src/init.js --delay 2 --ignore '.scss' --ignore 'static' ",
    "dev:assets": "cd src && cross-env WEBPACK_ENV=development webpack -w",
    "build:assets": "cd src && cross-env WEBPACK_ENV=production webpack",
    "build:server": "babel src --out-dir build",
    "copyAll": "xcopy .\\src\\static .\\build\\static\\ /s /y && xcopy .\\src\\views .\\build\\views\\ /s /y && xcopy .\\src\\uploads .\\build\\uploads",
    "build": "npm run build:assets && npm run build:server && npm run copyAll",
    "prebuild": "rd /s /q build",
    "tunnel": "ngrok http 4000",
    "start": "PRODUCTION=true node build/init.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/qudgus21/utube.git"
  },
  "author": "hwang",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/qudgus21/utube/issues"
  },
  "homepage": "https://github.com/qudgus21/utube#readme",
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.4.4",
    "eslint": "^5.16.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^4.2.0",
    "eslint-plugin-import": "^2.17.2",
    "eslint-plugin-prettier": "^3.0.1",
    "nodemon": "^1.19.0",
    "prettier": "^1.17.0"
  },
  "dependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.4",
    "@babel/node": "^7.4.5",
    "@babel/polyfill": "^7.4.4",
    "@babel/preset-env": "^7.4.4",
    "@babel/runtime": "^7.4.5",
    "autoprefixer": "^9.5.1",
    "aws-sdk": "^2.463.0",
    "axios": "^0.18.0",
    "babel-loader": "^8.0.5",
    "body-parser": "^1.19.0",
    "connect-mongo": "^2.0.3",
    "cookie-parser": "^1.4.4",
    "cross-env": "^5.2.0",
    "css-loader": "^2.1.1",
    "dotenv": "^8.0.0",
    "express": "^4.16.4",
    "express-flash": "0.0.2",
    "express-session": "^1.16.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "flash": "^1.1.0",
    "helmet": "^3.18.0",
    "mongoose": "^5.5.6",
    "morgan": "^1.9.1",
    "multer": "^1.4.1",
    "multer-s3": "^2.9.0",
    "node-sass": "^4.12.0",
    "passport": "^0.4.0",
    "passport-github": "^1.1.0",
    "passport-local": "^1.0.0",
    "passport-local-mongoose": "^5.0.1",
    "postcss-loader": "^3.0.0",
    "pug": "^2.0.3",
    "sass-loader": "^7.1.0",
    "webpack": "^4.30.0",
    "webpack-cli": "^3.3.2"
  },
  "engines": {
    "node": "10.15.3",
    "npm": "6.4.1"
  }
}
</code>```

and this is error

```<code>PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> git push heroku master
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 8 threads
Compressing objects: 100% (81/81), done.
Writing objects: 100% (87/87), 152.95 KiB | 3.00 MiB/s, done.
Total 87 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  10.15.3
remote:        engines.npm (package.json):   6.4.1
remote:
remote:        Resolving node version 10.15.3...
remote:        Downloading and installing node 10.15.3...
remote:        npm 6.4.1 already installed with node
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > node-sass@4.12.0 install /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/install.js
remote:
remote:        Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-64_binding.node
remote:        Download complete
remote:        Binary saved to /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Caching binary to /tmp/npmcache.Ulx4H/node-sass/4.12.0/linux-x64-64_binding.node
remote:
remote:        > core-js@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/@babel/register/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js@2.6.9 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js-pure@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js-pure
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > node-sass@4.12.0 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/build.js
remote:
remote:        Binary found at /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Testing binary
remote:        Binary is fine
remote:
remote:        > nodemon@1.19.1 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/nodemon
remote:        > node bin/postinstall || exit 0
remote:
remote:        Love nodemon? You can now support the project via the open collective:
remote:         > https://opencollective.com/nodemon/donate
remote:
remote:
remote:        > webpack-cli@3.3.2 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/webpack-cli
remote:        > node ./bin/opencollective.js
remote:
remote:
remote:
remote:                                    Thanks for using Webpack!
remote:                         Please consider donating to our Open Collective
remote:                                to help us maintain this package.
remote:
remote:
remote:
remote:                         Donate: https://opencollective.com/webpack/donate
remote:
remote:
remote:        added 1057 packages from 584 contributors and audited 12558 packages in 26.182s
remote:        found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote:        Running build
remote:
remote:        > utube@1.0.0 prebuild /tmp/build_7084f666a522aa57ba16b83206ec0b94
remote:        > rd /s /q build
remote:
remote: sh: 1: rd: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! utube@1.0.0 prebuild: `rd /s /q build`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the utube@1.0.0 prebuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.Ulx4H/_logs/2019-05-30T11_43_28_551Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to protected-depths-46400.
remote:
To https://git.heroku.com/protected-depths-46400.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/protected-depths-46400.git'
</code>```

答:
You have a prebuild script that won't work on Heroku:

```<code>"prebuild": "rd /s /q build",
</code>```

rd is a Windows command, but Heroku doesn't run Windows. This is reflected in your error message:

```<code>sh: 1: rd: not found
</code>```

It looks like you're trying to delete your build directory before building. But I don't think this is necessary. Certainly on Heroku it won't be required since each build is done in a clean environment. Try taking it out.

Edit: Your issue with xcopy is the same: this is a Windows command.

Since you actually need this step, consider depending on something like shx so you can rewrite that script in a cross-platform manner. I don't have a Windows machine handy at the moment, but something like

```<code>"devDependencies": {
  "shx": "^0.3.2",
},
</code>```

and

```<code>"scripts": {
  "copyAll": "shx cp -r src/static build/static && shx cp -r src/views build/views && shx cp -r src/uploads build/uploads",
},
</code>```

should work.

If it turns out you do need your prebuild step you should also be able to use shx there, e.g.

```<code>"prebuild": "shx rm -r build"
</code>```

Body:
(additional error)

PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku open
PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> heroku logs --tail
2019-05-31T16:45:02.171005+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:02.171116+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:02.171314+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.171426+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:02.171546+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.179317+00:00 app[web.1]:
2019-05-31T16:45:02.179463+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.179533+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_172Z-debug.log
2019-05-31T16:45:02.185867+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:02.186262+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:02.187262+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:02.187389+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:02.187579+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:02.187687+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:02.187797+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:02.193111+00:00 app[web.1]:
2019-05-31T16:45:02.193255+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:02.193337+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_02_188Z-debug.log
2019-05-31T16:45:02.258650+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:02.266584+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:45:02.249741+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:45:07.723357+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:45:09.873974+00:00 app[web.1]:
2019-05-31T16:45:09.874005+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:45:09.874008+00:00 app[web.1]: > npm run build
2019-05-31T16:45:09.874009+00:00 app[web.1]:
2019-05-31T16:45:10.385932+00:00 app[web.1]:
2019-05-31T16:45:10.385960+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:45:10.385962+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:45:10.385964+00:00 app[web.1]:
2019-05-31T16:45:10.396373+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:45:10.403250+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:45:10.403532+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.403769+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:45:10.404003+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:45:10.405101+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:45:10.405275+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:45:10.405526+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.405698+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:45:10.405864+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.413990+00:00 app[web.1]:
2019-05-31T16:45:10.414188+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.414314+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_407Z-debug.log
2019-05-31T16:45:10.442078+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:45:10.445480+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:45:10.451107+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:45:10.451370+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:45:10.451711+00:00 app[web.1]: npm ERR!
2019-05-31T16:45:10.453601+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:45:10.456332+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:45:10.466855+00:00 app[web.1]:
2019-05-31T16:45:10.467160+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:45:10.467324+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_45_10_460Z-debug.log
2019-05-31T16:45:10.550003+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:45:10.537734+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:23.749632+00:00 app[api]: Set PORT, MONGO_URL_PROD, MONGO_URL, COOKIE_SECRET, AWS_KEY, AWS_PW config vars by user hbh4231@gmail.com
2019-05-31T16:47:23.749632+00:00 app[api]: Release v4 created by user hbh4231@gmail.com
2019-05-31T16:47:24.905228+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-31T16:47:29.835194+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-31T16:47:32.064545+00:00 app[web.1]:
2019-05-31T16:47:32.064571+00:00 app[web.1]: > utube@1.0.0 prestart /app
2019-05-31T16:47:32.064573+00:00 app[web.1]: > npm run build
2019-05-31T16:47:32.064575+00:00 app[web.1]:
2019-05-31T16:47:32.469293+00:00 app[web.1]:
2019-05-31T16:47:32.469338+00:00 app[web.1]: > utube@1.0.0 prebuild /app
2019-05-31T16:47:32.469341+00:00 app[web.1]: > shx rm -rf build
2019-05-31T16:47:32.469343+00:00 app[web.1]:
2019-05-31T16:47:32.475344+00:00 app[web.1]: sh: 1: shx: not found
2019-05-31T16:47:32.479177+00:00 app[web.1]: npm ERR! file sh
2019-05-31T16:47:32.479507+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.479713+00:00 app[web.1]: npm ERR! errno ENOENT
2019-05-31T16:47:32.479949+00:00 app[web.1]: npm ERR! syscall spawn
2019-05-31T16:47:32.481275+00:00 app[web.1]: npm ERR! utube@1.0.0 prebuild: `shx rm -rf build`
2019-05-31T16:47:32.481386+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-05-31T16:47:32.481567+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.481732+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prebuild script.
2019-05-31T16:47:32.481842+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.490356+00:00 app[web.1]:
2019-05-31T16:47:32.490515+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.490598+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_483Z-debug.log
2019-05-31T16:47:32.497599+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-31T16:47:32.498150+00:00 app[web.1]: npm ERR! errno 1
2019-05-31T16:47:32.499418+00:00 app[web.1]: npm ERR! utube@1.0.0 prestart: `npm run build`
2019-05-31T16:47:32.499643+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-31T16:47:32.499909+00:00 app[web.1]: npm ERR!
2019-05-31T16:47:32.500099+00:00 app[web.1]: npm ERR! Failed at the utube@1.0.0 prestart script.
2019-05-31T16:47:32.500279+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-31T16:47:32.507354+00:00 app[web.1]:
2019-05-31T16:47:32.507595+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-31T16:47:32.507739+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-31T16_47_32_501Z-debug.log
2019-05-31T16:47:32.574723+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-31T16:47:32.562071+00:00 heroku[web.1]: Process exited with status 1
2019-05-31T16:47:54.648467+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=648f1dcd-fd24-4008-9316-9c5064c48981 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:47:55.002820+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=9e0aef22-1945-4863-843d-c9b06395c19c fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.197785+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=4498ed4d-0722-42bd-b3a9-a1cdccd2808e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:03.601213+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=8e23955e-771d-42a1-a381-239137799a1e fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.440580+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=e33dde27-d710-45c8-ae47-88a211109e87 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:04.799842+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=2b7bde17-2418-44e4-baaf-8ceb38f61381 fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.019477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=afternoon-wildwood-60220.herokuapp.com request_id=5bf7c128-f282-4ceb-8f31-2aac4e3588ec fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https
2019-05-31T16:48:06.410926+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=afternoon-wildwood-60220.herokuapp.com request_id=88024c5c-027d-49e3-ba51-14b556f3a3fe fwd="118.221.72.173" dyno= connect= service= status=503 bytes= protocol=https

I am beginner and want to deploy express app using heroku but error has occured.

First I enter commend heroku create and it works. but next when I enter git push heroku master, error happened. I will add my package.json and error log.

error point is `git push heroku master

this is package.json:

{
  "name": "utube",
  "version": "1.0.0",
  "description": "clone youtube",
  "scripts": {
    "dev:server": "nodemon --exec babel-node src/init.js --delay 2 --ignore '.scss' --ignore 'static' ",
    "dev:assets": "cd src && cross-env WEBPACK_ENV=development webpack -w",
    "build:assets": "cd src && cross-env WEBPACK_ENV=production webpack",
    "build:server": "babel src --out-dir build",
    "copyAll": "xcopy .\\src\\static .\\build\\static\\ /s /y && xcopy .\\src\\views .\\build\\views\\ /s /y && xcopy .\\src\\uploads .\\build\\uploads",
    "build": "npm run build:assets && npm run build:server && npm run copyAll",
    "prebuild": "rd /s /q build",
    "tunnel": "ngrok http 4000",
    "start": "PRODUCTION=true node build/init.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/qudgus21/utube.git"
  },
  "author": "hwang",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/qudgus21/utube/issues"
  },
  "homepage": "https://github.com/qudgus21/utube#readme",
  "devDependencies": {
    "@babel/plugin-transform-runtime": "^7.4.4",
    "eslint": "^5.16.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^4.2.0",
    "eslint-plugin-import": "^2.17.2",
    "eslint-plugin-prettier": "^3.0.1",
    "nodemon": "^1.19.0",
    "prettier": "^1.17.0"
  },
  "dependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.4",
    "@babel/node": "^7.4.5",
    "@babel/polyfill": "^7.4.4",
    "@babel/preset-env": "^7.4.4",
    "@babel/runtime": "^7.4.5",
    "autoprefixer": "^9.5.1",
    "aws-sdk": "^2.463.0",
    "axios": "^0.18.0",
    "babel-loader": "^8.0.5",
    "body-parser": "^1.19.0",
    "connect-mongo": "^2.0.3",
    "cookie-parser": "^1.4.4",
    "cross-env": "^5.2.0",
    "css-loader": "^2.1.1",
    "dotenv": "^8.0.0",
    "express": "^4.16.4",
    "express-flash": "0.0.2",
    "express-session": "^1.16.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "flash": "^1.1.0",
    "helmet": "^3.18.0",
    "mongoose": "^5.5.6",
    "morgan": "^1.9.1",
    "multer": "^1.4.1",
    "multer-s3": "^2.9.0",
    "node-sass": "^4.12.0",
    "passport": "^0.4.0",
    "passport-github": "^1.1.0",
    "passport-local": "^1.0.0",
    "passport-local-mongoose": "^5.0.1",
    "postcss-loader": "^3.0.0",
    "pug": "^2.0.3",
    "sass-loader": "^7.1.0",
    "webpack": "^4.30.0",
    "webpack-cli": "^3.3.2"
  },
  "engines": {
    "node": "10.15.3",
    "npm": "6.4.1"
  }
}

and this is error

PS C:\Users\Hwang byeong hyeon\Desktop\portfolio\utube> git push heroku master
Enumerating objects: 87, done.
Counting objects: 100% (87/87), done.
Delta compression using up to 8 threads
Compressing objects: 100% (81/81), done.
Writing objects: 100% (87/87), 152.95 KiB | 3.00 MiB/s, done.
Total 87 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  10.15.3
remote:        engines.npm (package.json):   6.4.1
remote:
remote:        Resolving node version 10.15.3...
remote:        Downloading and installing node 10.15.3...
remote:        npm 6.4.1 already installed with node
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > node-sass@4.12.0 install /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/install.js
remote:
remote:        Downloading binary from https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-64_binding.node
remote:        Download complete
remote:        Binary saved to /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Caching binary to /tmp/npmcache.Ulx4H/node-sass/4.12.0/linux-x64-64_binding.node
remote:
remote:        > core-js@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/@babel/register/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js@2.6.9 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > core-js-pure@3.1.3 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/core-js-pure
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:
remote:        > node-sass@4.12.0 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass
remote:        > node scripts/build.js
remote:
remote:        Binary found at /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/node-sass/vendor/linux-x64-64/binding.node
remote:        Testing binary
remote:        Binary is fine
remote:
remote:        > nodemon@1.19.1 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/nodemon
remote:        > node bin/postinstall || exit 0
remote:
remote:        Love nodemon? You can now support the project via the open collective:
remote:         > https://opencollective.com/nodemon/donate
remote:
remote:
remote:        > webpack-cli@3.3.2 postinstall /tmp/build_7084f666a522aa57ba16b83206ec0b94/node_modules/webpack-cli
remote:        > node ./bin/opencollective.js
remote:
remote:
remote:
remote:                                    Thanks for using Webpack!
remote:                         Please consider donating to our Open Collective
remote:                                to help us maintain this package.
remote:
remote:
remote:
remote:                         Donate: https://opencollective.com/webpack/donate
remote:
remote:
remote:        added 1057 packages from 584 contributors and audited 12558 packages in 26.182s
remote:        found 0 vulnerabilities
remote:
remote:
remote: -----> Build
remote:        Running build
remote:
remote:        > utube@1.0.0 prebuild /tmp/build_7084f666a522aa57ba16b83206ec0b94
remote:        > rd /s /q build
remote:
remote: sh: 1: rd: not found
remote: npm ERR! file sh
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno ENOENT
remote: npm ERR! syscall spawn
remote: npm ERR! utube@1.0.0 prebuild: `rd /s /q build`
remote: npm ERR! spawn ENOENT
remote: npm ERR!
remote: npm ERR! Failed at the utube@1.0.0 prebuild script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /tmp/npmcache.Ulx4H/_logs/2019-05-30T11_43_28_551Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        If you're stuck, please submit a ticket so we can help:
remote:        https://help.heroku.com/
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to protected-depths-46400.
remote:
To https://git.heroku.com/protected-depths-46400.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/protected-depths-46400.git'

Body:
You have a prebuild script that won't work on Heroku:

"prebuild": "rd /s /q build",

rd is a Windows command, but Heroku doesn't run Windows. This is reflected in your error message:

sh: 1: rd: not found

It looks like you're trying to delete your build directory before building. But I don't think this is necessary. Certainly on Heroku it won't be required since each build is done in a clean environment. Try taking it out.

Edit: Your issue with xcopy is the same: this is a Windows command.

Since you actually need this step, consider depending on something like shx so you can rewrite that script in a cross-platform manner. I don't have a Windows machine handy at the moment, but something like

"devDependencies": {
  "shx": "^0.3.2",
},

and

"scripts": {
  "copyAll": "shx cp -r src/static build/static && shx cp -r src/views build/views && shx cp -r src/uploads build/uploads",
},

should work.

If it turns out you do need your prebuild step you should also be able to use shx there, e.g.

"prebuild": "shx rm -r build"


来源: stackexchange

问:
'Certificate' Option missing from Windows 10 Enterprise VPN connection properties
When trying to connect to an Azure VPN, I noticed that the 'Certificate' option is missing from my version of Windows 10 when I try to edit the VPN connection properties. The only options listed are 'Username and password', 'Smart card' and 'One-time password'.

How would I go about getting the certificate option added?

Windows version:
Microsoft Windows 10 Enterprise 2015 LTSB
Version 10.0.10240 Build 10240

答:
My solution was to download and install the latest Windows updates in my case this was:

Windows 10 version 1809 - Windows 10 May 2019 Update

This espesially important in your in place upgrade or new install was from a local media and you did not select download latest updates during the Windows 10 installation process.

ContentLicense: CC BY-SA 4.0


问:
How can i update an existing field in a table using VBA
The program i'm working on in a simple inbound/outbound date/timestamp. An entry is added to the table for an inbound truck then when when the truck leaves an outbound entry is added. In the outbound form is a drop down list of everything that has come inbound but not outbound. This allows the user to select which entry needs to be updated. I'm stuck trying to get the information for the outbound portion into the already created field. I was trying to edit the table only if the selected entry is equal to the id in the table. Is there something i am missing? or is there a better way to approach this?

I got the information into the table using but it doesn't update the selected record.

```<code>Private Sub Inbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("T_Sitelog")

    Sitelog.AddNew
    Sitelog![Trailer_Type] = Me![TrailerType]
    Sitelog![Trailer_Num] = Me![TrailerNum]
    Sitelog![Carrier] = Me![Carrier]
    Sitelog![T/D_IN] = Me![TDStamp_IN]
    Sitelog![Inbound_Comments] = Me![Comments_IN]
    Sitelog.Update
End Sub

Private Sub Outbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("T_Sitelog Where ID = " & _
        Me!TrailersOnProperty.Column(0))

    Sitelog.Edit
    Sitelog![T/D_OUT] = Me![TDStamp_OUT]
    Sitelog![Outbound_Comments] = Me![Comments_OUT]
    Sitelog.Update
End Sub
</code>```

I except the result to update the already existing record added in the inbound portion. A date/timestamp and comments should be updated into the table.

答:
Make sure the Bound Column property of TrailersOnProperty is set to 0 and then try this:

```<code>Private Sub Outbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("SELECT * FROM T_Sitelog WHERE ID = " & Me!TrailersOnProperty)
    Sitelog.MoveFirst
    Sitelog.Edit
    Sitelog![T/D_OUT] = Me![TDStamp_OUT]
    Sitelog![Outbound_Comments] = Me![Comments_OUT]
    Sitelog.Update
End Sub
</code>```

You can either use a table/query name or a proper SQL query for recordsets. A table name followed by a WHERE clause is neither. Also there is no guarantee that when you open the recordset the cursor will be at the first record. It could easily be at EOF.

Body:
The program i'm working on in a simple inbound/outbound date/timestamp. An entry is added to the table for an inbound truck then when when the truck leaves an outbound entry is added. In the outbound form is a drop down list of everything that has come inbound but not outbound. This allows the user to select which entry needs to be updated. I'm stuck trying to get the information for the outbound portion into the already created field. I was trying to edit the table only if the selected entry is equal to the id in the table. Is there something i am missing? or is there a better way to approach this?

I got the information into the table using but it doesn't update the selected record.

Private Sub Inbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("T_Sitelog")

    Sitelog.AddNew
    Sitelog![Trailer_Type] = Me![TrailerType]
    Sitelog![Trailer_Num] = Me![TrailerNum]
    Sitelog![Carrier] = Me![Carrier]
    Sitelog![T/D_IN] = Me![TDStamp_IN]
    Sitelog![Inbound_Comments] = Me![Comments_IN]
    Sitelog.Update
End Sub

Private Sub Outbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("T_Sitelog Where ID = " & _
        Me!TrailersOnProperty.Column(0))

    Sitelog.Edit
    Sitelog![T/D_OUT] = Me![TDStamp_OUT]
    Sitelog![Outbound_Comments] = Me![Comments_OUT]
    Sitelog.Update
End Sub

I except the result to update the already existing record added in the inbound portion. A date/timestamp and comments should be updated into the table.

Body:
Make sure the Bound Column property of TrailersOnProperty is set to 0 and then try this:

Private Sub Outbound_Click()
    Set mydb = DBEngine(0)(0)
    Set Sitelog = mydb.OpenRecordset("SELECT * FROM T_Sitelog WHERE ID = " & Me!TrailersOnProperty)
    Sitelog.MoveFirst
    Sitelog.Edit
    Sitelog![T/D_OUT] = Me![TDStamp_OUT]
    Sitelog![Outbound_Comments] = Me![Comments_OUT]
    Sitelog.Update
End Sub

You can either use a table/query name or a proper SQL query for recordsets. A table name followed by a WHERE clause is neither. Also there is no guarantee that when you open the recordset the cursor will be at the first record. It could easily be at EOF.


问:
is it possible to open a link from ionic cordova app from ios platform in microsoft-edge browser
I have an ionic cordova app, on ios platform , i want to open some links in edge browser rather than the inappbrowser or the default browser.

i have gone through a number of articles, and have tried a lot of things but nothing seems to work for me.
I have also made changes in info.plist of project and added the urlschema. the code i'm using to open link is mentioned below
:

```<code>const browser = window.open('microsoft-edge:'+ 'https://google.com' ,'_blank');
</code>```

答:
But you could try the following
https://github.com/apache/cordova-plugin-inappbrowser/releases

OSX Quirk
At the moment the only supported target in OSX is _system.

So if device system browser set to edge

Body:
I have an ionic cordova app, on ios platform , i want to open some links in edge browser rather than the inappbrowser or the default browser.

i have gone through a number of articles, and have tried a lot of things but nothing seems to work for me.
I have also made changes in info.plist of project and added the urlschema. the code i'm using to open link is mentioned below
:

const browser = window.open('microsoft-edge:'+ 'https://google.com' ,'_blank');


问:
How to display blocks of text in drupal?
I'm trying to build a module that lets users with a certain role post messages that will be displayed for users with a different role. I'd like this to simply be one module that handles both these things, however, the furthest I've gotten is setting up the form to post messages.

I'd like to show the posted messages on the same page as the input form (and hide the form for the unauthorised users), but I just can't figure out what I have to do to show the messages. How hard can it be to display some simple text?

So far I've added an item to the menu that links to the page with a form on it.

答: You could make use of the boxes module to have online editing of this text that other users will see. If you're set on Using your custom Form you could put your text in a block.</p>

ContentLicense: CC BY-SA 3.0


问:
java.lang.IllegalStateException: Failed to load ApplicationContext ,springboot setting
The following is the error message

java.lang.IllegalStateException: Failed to load ApplicationContext

at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
  at
  org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
  at
  org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
  at
  org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
  at
  org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
  at
  org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
  org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at
  org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
  org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at
  org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at
  org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at
  org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at
  com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at
  com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at
  com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at
  com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by:
  org.springframework.beans.factory.UnsatisfiedDependencyException:
  Error creating bean with name 'wokerLogController': Unsatisfied
  dependency expressed through field 'client'; nested exception is
  org.springframework.beans.factory.BeanCreationException: Error
  creating bean with name 'client' defined in class path resource
  [com/aurora/backend/config/ESConfig.class]: Bean instantiation via
  factory method failed; nested exception is
  org.springframework.beans.BeanInstantiationException: Failed to
  instantiate [org.elasticsearch.client.Client]: Factory method 'client'
  threw exception; nested exception is java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
  at
  org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
  at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  at
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
  at
  org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
  at
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
  at
  org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
  at
  org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
  at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
  at
  org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
  at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
  at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
  ... 24 more

Caused by: org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'client' defined in class path resource
  [com/aurora/backend/config/ESConfig.class]: Bean instantiation via
  factory method failed; nested exception is
  org.springframework.beans.BeanInstantiationException: Failed to
  instantiate [org.elasticsearch.client.Client]: Factory method 'client'
  threw exception; nested exception is java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
  at
  org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  at
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  at
  org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1244)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
  at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
  ... 42 more

Caused by: org.springframework.beans.BeanInstantiationException:
  Failed to instantiate [org.elasticsearch.client.Client]: Factory
  method 'client' threw exception; nested exception is
  java.lang.IllegalStateException: availableProcessors is already set to
  [4], rejecting [4] at
  org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
  at
  org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
  ... 55 more Caused by: java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51)
  at
  io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87)
  at
  org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:83)
  at
  org.elasticsearch.transport.netty4.Netty4Transport.(Netty4Transport.java:112)
  at
  org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:86)
  at
  org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:189)
  at
  org.elasticsearch.client.transport.TransportClient.(TransportClient.java:283)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:128)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:114)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:104)
  at com.aurora.backend.config.ESConfig.client(ESConfig.java:45) at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a.CGLIB$client$0()
  at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a$$FastClassBySpringCGLIB$$93c49e6a.invoke()
  at
  org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
  at
  org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
  at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a.client()
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498) at
  org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
  ... 56 more

A springboot project that uses elasticSearch, mysql, redis, etc.
Google has a lot, but he is just a new spingboot. The online stuff doesn't work. I don't know how to change it.

application-local.yml

```<code>server:
  port: 8000
  servlet:
    context-path: /api/v3
  error:
    whitelabel:
      enabled: false

spring:
  http:
    multipart:

    encoding:
      charset: UTF-8
      force: true
      enabled: true

  datasource:
    url: jdbc:mysql://localhost:3306/aurora?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
    username: root
    password: 123456789
    driverClassName: com.mysql.jdbc.Driver
  jpa:
    database-platform: org.hibernate.dialect.MySQL57Dialect
    generate-ddl: true
    show-sql: true
  liquibase:
    change-log: classpath:db/db.master.xml
  data:
    elasticsearch:
      cluster-name: elasticsearch
      cluster-nodes: 127.0.0.1:9300
      repositories:
        enabled: true
  redis:
    host: 127.0.0.1
    port: 6379
    password:
    database: 0
    lettuce:
      pool:
        max-active: 8
        max-wait: -1
        max-idle: 8
        min-idle: 0
        timeout: 0
  servlet:
    multipart:
      max-file-size: 200MB # Max file size.
      max-request-size: 215MB # Max Request Size
      enabled: true

logging:
  pattern:
    file: "%d{yy-MM-dd HH:mm:ss.SSS} [%thread] %-5level : %X{user} %logger{36}.%M - %msg%n"
    console: "%d{yy-MM-dd HH:mm:ss.SSS} [%thread] %-5level : %X{user} %logger{36}.%M - %msg%n"
  level:
    org.springframework.web: DEBUG
    guru.springframework.controllers: DEBUG
    org.hibernate: DEBUG

app:
  wechat:
    notification: true
  design:
    root-path: /home/cloudeda/Aurora/UploadData
  jwt:
    base64-secret: NjkwNjU5ZTg0YmYxZmE0ZDJmYmFlNmMwMGNjMjJjZTc4MjFiZjkyNTk3N2IyN2M5OGQyNzg3ZTExN2M1MGYzMzNkNTg2MzMwODgzZTE3YzIwMDdhMTg1Y2M4ZWFmYmFjOGEyYWNiOTU3ZGYzNTY3NDdmMzg3ZWNjNjRmNjdjNzI=
    # Token is valid 24 hours
    token-validity-in-seconds: 86400
    token-validity-in-seconds-for-remember-me: 2592000
  id:
    data-center: 1
    machine: 1

  server:
    broker: tcp://localhost:5555
  flask:
    ibis-parser-url: http://localhost:5050/api/v3/server/parse-ibis-model
    generate-report-url: http://localhost:5050/api/v3/server/report

security:
  user:
    name: aurora
    password: aurora-monitor-password

elasticsearch:
  host: 127.0.0.1
  port: 9300
  cluster:
    name: elasticsearch
</code>```

Should be related to the configuration of the ES

ESConfig.java

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;

@Configuration
public class ESConfig {

    @Value("${elasticsearch.host:127.0.0.1}")
    private String host;

    @Value("${elasticsearch.port:9300}")
    private int port;

    @Value("${elasticsearch.cluster.name:elasticsearch}")
    private String clusterName;

    public String getHost() {
        return this.host;
    }

    public int getPort() {
        return this.port;
    }

    @Bean
    public Client client() {
        TransportClient client = null;

        Settings settings = Settings.builder()
            .put("cluster.name", clusterName)
            .put("client.transport.ignore_cluster_name", false)
            .build();

        try {
            client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new TransportAddress(InetAddress.getByName(host), port));
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

        return client;
    }
}
```

<p><strong>Controller</strong></p>

<pre class="lang-java prettyprint-override"><code>import com.aurora.backend.beans.ResultBean;
import com.aurora.backend.beans.WorkerLogBean;
import com.aurora.backend.param.SearchSimulationLogParam;
import com.aurora.backend.security.CurrentUser;
import com.aurora.backend.security.UserPrincipal;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/es")
@Slf4j
public class WokerLogController {

    @Autowired Client client;

    @PostMapping(value = "/simulation/log")
    public ResultBean getSimulationLog(
        @CurrentUser UserPrincipal user,
        @RequestBody SearchSimulationLogParam param
    ) {

        SearchResponse response = client.prepareSearch("logstash-worker")
            .setTypes("doc")
            .setSearchType(SearchType.QUERY_THEN_FETCH)
            .setQuery(QueryBuilders.matchQuery("logtype", 1))
            .setQuery(QueryBuilders.matchQuery("token", param.getToken()))
            .setPostFilter(
                QueryBuilders.rangeQuery("@timestamp")
                    .from(param.getStartTime()).to(param.getEndTime()))
            .get();

        SearchHit[] hits = response.getHits().getHits();
        List<WorkerLogBean> mapList = new ArrayList<>();
        for (int i = 0; i < hits.length; i++) {
            WorkerLogBean logBean = new WorkerLogBean();
            logBean.setId(hits[i].getId());
            logBean.setLog(hits[i].getSourceAsMap().get("log").toString());
            logBean.setMessage(hits[i].getSourceAsMap().get("message").toString());
            mapList.add(logBean);
        }
        return new ResultBean(mapList);
    }
}
</code>```

答:
It could be a dependency issue. Anyway, if you are using spring boot 2.., go with rest client instead of transport client which is deprecated.

Use the following code:
build.gradle:

```<code>compile "com.fasterxml.jackson.datatype:jackson-datatype-hppc"
    compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
    compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5"
    compile "com.fasterxml.jackson.core:jackson-annotations"
    compile "com.fasterxml.jackson.core:jackson-databind"
    compile "com.fasterxml.jackson.module:jackson-module-afterburner"
    runtime group: 'com.fasterxml.jackson.module', name: 'jackson-modules-java8', version: '2.9.8', ext: 'pom'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-parameter-names
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.8'

compile 'org.elasticsearch:elasticsearch'
    compile 'org.elasticsearch.client:transport'
    compile 'org.elasticsearch.client:elasticsearch-rest-client'
    compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client'

    compile 'org.springframework.data:spring-data-elasticsearch'
</code>```

Versions: Should be Compatible

```<code>org.elasticsearch.client:elasticsearch-rest-client -> 6.4.3 (*)
org.elasticsearch.client:elasticsearch-rest-high-level-client -> 6.4.3
org.elasticsearch:elasticsearch -> 6.4.3
org.springframework.data:spring-data-elasticsearch -> 3.1.4.RELEASE
com.fasterxml.jackson.datatype:jackson-datatype-hppc -> 2.9.8
com.fasterxml.jackson.core:jackson-core:2.9.8
com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> 2.9.8 (*)
com.fasterxml.jackson.datatype:jackson-datatype-hibernate5 -> 2.9.8
com.fasterxml.jackson.core:jackson-annotations -> 2.9.0
com.fasterxml.jackson.module:jackson-module-afterburner -> 2.9.8
com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8 (*)
com.fasterxml.jackson.module:jackson-modules-java8:2.9.8
</code>```

ElasticSearchConfiguration:

RestHighLevelClient client = null;

@Bean
public RestHighLevelClient buildClient() {
    return new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("localhost", 9200, "http"),
                    new HttpHost("localhost", 9201, "http")));
}

@Bean
@Primary
public ElasticsearchOperations elasticsearchTemplate() {
    return new ElasticsearchTemplate((Client) buildClient(), new CustomEntityMapper(new ObjectMapper()));
}

public class CustomEntityMapper implements EntityMapper {

    private ObjectMapper objectMapper;

    public CustomEntityMapper(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        //objectMapper.registerModule(new JavaTimeModule());
        JavaTimeModule javaTimeModule=new JavaTimeModule();
        // Hack time module to allow 'Z' at the end of string (i.e. javascript json's)
        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ISO_DATE_TIME));
        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_DATE));
        objectMapper.registerModule(javaTimeModule);

        objectMapper.findAndRegisterModules();
    }

    @Override
    public String mapToString(Object object) throws IOException {
        return objectMapper.writeValueAsString(object);
    }

    @Override
    public <T> T mapToObject(String source, Class<T> clazz) throws IOException {
        return objectMapper.readValue(source, clazz);
    }
}
```

Body:
The following is the error message

java.lang.IllegalStateException: Failed to load ApplicationContext

at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
  at
  org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
  at
  org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
  at
  org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
  at
  org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
  at
  org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
  at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at
  org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at
  org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at
  org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at
  org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at
  org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at
  org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at
  org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at
  com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at
  com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at
  com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at
  com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Caused by:
  org.springframework.beans.factory.UnsatisfiedDependencyException:
  Error creating bean with name 'wokerLogController': Unsatisfied
  dependency expressed through field 'client'; nested exception is
  org.springframework.beans.factory.BeanCreationException: Error
  creating bean with name 'client' defined in class path resource
  [com/aurora/backend/config/ESConfig.class]: Bean instantiation via
  factory method failed; nested exception is
  org.springframework.beans.BeanInstantiationException: Failed to
  instantiate [org.elasticsearch.client.Client]: Factory method 'client'
  threw exception; nested exception is java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
  at
  org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
  at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  at
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
  at
  org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
  at
  org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
  at
  org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
  at
  org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
  at
  org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
  at
  org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127)
  at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
  at
  org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
  ... 24 more

Caused by: org.springframework.beans.factory.BeanCreationException:
  Error creating bean with name 'client' defined in class path resource
  [com/aurora/backend/config/ESConfig.class]: Bean instantiation via
  factory method failed; nested exception is
  org.springframework.beans.BeanInstantiationException: Failed to
  instantiate [org.elasticsearch.client.Client]: Factory method 'client'
  threw exception; nested exception is java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
  at
  org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
  at
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
  at
  org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
  at
  org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
  at
  org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1244)
  at
  org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
  at
  org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
  ... 42 more

Caused by: org.springframework.beans.BeanInstantiationException:
  Failed to instantiate [org.elasticsearch.client.Client]: Factory
  method 'client' threw exception; nested exception is
  java.lang.IllegalStateException: availableProcessors is already set to
  [4], rejecting [4] at
  org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
  at
  org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
  ... 55 more Caused by: java.lang.IllegalStateException:
  availableProcessors is already set to [4], rejecting [4] at
  io.netty.util.NettyRuntime$AvailableProcessorsHolder.setAvailableProcessors(NettyRuntime.java:51)
  at
  io.netty.util.NettyRuntime.setAvailableProcessors(NettyRuntime.java:87)
  at
  org.elasticsearch.transport.netty4.Netty4Utils.setAvailableProcessors(Netty4Utils.java:83)
  at
  org.elasticsearch.transport.netty4.Netty4Transport.(Netty4Transport.java:112)
  at
  org.elasticsearch.transport.Netty4Plugin.lambda$getTransports$0(Netty4Plugin.java:86)
  at
  org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:189)
  at
  org.elasticsearch.client.transport.TransportClient.(TransportClient.java:283)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:128)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:114)
  at
  org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:104)
  at com.aurora.backend.config.ESConfig.client(ESConfig.java:45) at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a.CGLIB$client$0()
  at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a$$FastClassBySpringCGLIB$$93c49e6a.invoke()
  at
  org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
  at
  org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
  at
  com.aurora.backend.config.ESConfig$$EnhancerBySpringCGLIB$$d0b29c5a.client()
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498) at
  org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
  ... 56 more

A springboot project that uses elasticSearch, mysql, redis, etc.
Google has a lot, but he is just a new spingboot. The online stuff doesn't work. I don't know how to change it.

application-local.yml

server:
  port: 8000
  servlet:
    context-path: /api/v3
  error:
    whitelabel:
      enabled: false

spring:
  http:
    multipart:

    encoding:
      charset: UTF-8
      force: true
      enabled: true

  datasource:
    url: jdbc:mysql://localhost:3306/aurora?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
    username: root
    password: 123456789
    driverClassName: com.mysql.jdbc.Driver
  jpa:
    database-platform: org.hibernate.dialect.MySQL57Dialect
    generate-ddl: true
    show-sql: true
  liquibase:
    change-log: classpath:db/db.master.xml
  data:
    elasticsearch:
      cluster-name: elasticsearch
      cluster-nodes: 127.0.0.1:9300
      repositories:
        enabled: true
  redis:
    host: 127.0.0.1
    port: 6379
    password:
    database: 0
    lettuce:
      pool:
        max-active: 8
        max-wait: -1
        max-idle: 8
        min-idle: 0
        timeout: 0
  servlet:
    multipart:
      max-file-size: 200MB # Max file size.
      max-request-size: 215MB # Max Request Size
      enabled: true

logging:
  pattern:
    file: "%d{yy-MM-dd HH:mm:ss.SSS} [%thread] %-5level : %X{user} %logger{36}.%M - %msg%n"
    console: "%d{yy-MM-dd HH:mm:ss.SSS} [%thread] %-5level : %X{user} %logger{36}.%M - %msg%n"
  level:
    org.springframework.web: DEBUG
    guru.springframework.controllers: DEBUG
    org.hibernate: DEBUG

app:
  wechat:
    notification: true
  design:
    root-path: /home/cloudeda/Aurora/UploadData
  jwt:
    base64-secret: NjkwNjU5ZTg0YmYxZmE0ZDJmYmFlNmMwMGNjMjJjZTc4MjFiZjkyNTk3N2IyN2M5OGQyNzg3ZTExN2M1MGYzMzNkNTg2MzMwODgzZTE3YzIwMDdhMTg1Y2M4ZWFmYmFjOGEyYWNiOTU3ZGYzNTY3NDdmMzg3ZWNjNjRmNjdjNzI=
    # Token is valid 24 hours
    token-validity-in-seconds: 86400
    token-validity-in-seconds-for-remember-me: 2592000
  id:
    data-center: 1
    machine: 1

  server:
    broker: tcp://localhost:5555
  flask:
    ibis-parser-url: http://localhost:5050/api/v3/server/parse-ibis-model
    generate-report-url: http://localhost:5050/api/v3/server/report

security:
  user:
    name: aurora
    password: aurora-monitor-password

elasticsearch:
  host: 127.0.0.1
  port: 9300
  cluster:
    name: elasticsearch

Should be related to the configuration of the ES

ESConfig.java

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;

@Configuration
public class ESConfig {

    @Value("${elasticsearch.host:127.0.0.1}")
    private String host;

    @Value("${elasticsearch.port:9300}")
    private int port;

    @Value("${elasticsearch.cluster.name:elasticsearch}")
    private String clusterName;

    public String getHost() {
        return this.host;
    }

    public int getPort() {
        return this.port;
    }

    @Bean
    public Client client() {
        TransportClient client = null;

        Settings settings = Settings.builder()
            .put("cluster.name", clusterName)
            .put("client.transport.ignore_cluster_name", false)
            .build();

        try {
            client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new TransportAddress(InetAddress.getByName(host), port));
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

        return client;
    }
}

Controller

import com.aurora.backend.beans.ResultBean;
import com.aurora.backend.beans.WorkerLogBean;
import com.aurora.backend.param.SearchSimulationLogParam;
import com.aurora.backend.security.CurrentUser;
import com.aurora.backend.security.UserPrincipal;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "/es")
@Slf4j
public class WokerLogController {

    @Autowired Client client;

    @PostMapping(value = "/simulation/log")
    public ResultBean getSimulationLog(
        @CurrentUser UserPrincipal user,
        @RequestBody SearchSimulationLogParam param
    ) {

        SearchResponse response = client.prepareSearch("logstash-worker")
            .setTypes("doc")
            .setSearchType(SearchType.QUERY_THEN_FETCH)
            .setQuery(QueryBuilders.matchQuery("logtype", 1))
            .setQuery(QueryBuilders.matchQuery("token", param.getToken()))
            .setPostFilter(
                QueryBuilders.rangeQuery("@timestamp")
                    .from(param.getStartTime()).to(param.getEndTime()))
            .get();

        SearchHit[] hits = response.getHits().getHits();
        List<WorkerLogBean> mapList = new ArrayList<>();
        for (int i = 0; i < hits.length; i++) {
            WorkerLogBean logBean = new WorkerLogBean();
            logBean.setId(hits[i].getId());
            logBean.setLog(hits[i].getSourceAsMap().get("log").toString());
            logBean.setMessage(hits[i].getSourceAsMap().get("message").toString());
            mapList.add(logBean);
        }
        return new ResultBean(mapList);
    }
}

Body:
It could be a dependency issue. Anyway, if you are using spring boot 2.., go with rest client instead of transport client which is deprecated.

Use the following code:
build.gradle:

compile "com.fasterxml.jackson.datatype:jackson-datatype-hppc"
    compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
    compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5"
    compile "com.fasterxml.jackson.core:jackson-annotations"
    compile "com.fasterxml.jackson.core:jackson-databind"
    compile "com.fasterxml.jackson.module:jackson-module-afterburner"
    runtime group: 'com.fasterxml.jackson.module', name: 'jackson-modules-java8', version: '2.9.8', ext: 'pom'
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-parameter-names
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.8'

compile 'org.elasticsearch:elasticsearch'
    compile 'org.elasticsearch.client:transport'
    compile 'org.elasticsearch.client:elasticsearch-rest-client'
    compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client'

    compile 'org.springframework.data:spring-data-elasticsearch'

Versions: Should be Compatible

org.elasticsearch.client:elasticsearch-rest-client -> 6.4.3 (*)
org.elasticsearch.client:elasticsearch-rest-high-level-client -> 6.4.3
org.elasticsearch:elasticsearch -> 6.4.3
org.springframework.data:spring-data-elasticsearch -> 3.1.4.RELEASE
com.fasterxml.jackson.datatype:jackson-datatype-hppc -> 2.9.8
com.fasterxml.jackson.core:jackson-core:2.9.8
com.fasterxml.jackson.core:jackson-databind:2.9.8 (*)
com.fasterxml.jackson.datatype:jackson-datatype-jsr310 -> 2.9.8 (*)
com.fasterxml.jackson.datatype:jackson-datatype-hibernate5 -> 2.9.8
com.fasterxml.jackson.core:jackson-annotations -> 2.9.0
com.fasterxml.jackson.module:jackson-module-afterburner -> 2.9.8
com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8 (*)
com.fasterxml.jackson.module:jackson-modules-java8:2.9.8

ElasticSearchConfiguration:

RestHighLevelClient client = null;

@Bean
public RestHighLevelClient buildClient() {
    return new RestHighLevelClient(
            RestClient.builder(
                    new HttpHost("localhost", 9200, "http"),
                    new HttpHost("localhost", 9201, "http")));
}

@Bean
@Primary
public ElasticsearchOperations elasticsearchTemplate() {
    return new ElasticsearchTemplate((Client) buildClient(), new CustomEntityMapper(new ObjectMapper()));
}

public class CustomEntityMapper implements EntityMapper {

    private ObjectMapper objectMapper;

    public CustomEntityMapper(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        //objectMapper.registerModule(new JavaTimeModule());
        JavaTimeModule javaTimeModule=new JavaTimeModule();
        // Hack time module to allow 'Z' at the end of string (i.e. javascript json's)
        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ISO_DATE_TIME));
        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_DATE));
        objectMapper.registerModule(javaTimeModule);

        objectMapper.findAndRegisterModules();
    }

    @Override
    public String mapToString(Object object) throws IOException {
        return objectMapper.writeValueAsString(object);
    }

    @Override
    public <T> T mapToObject(String source, Class<T> clazz) throws IOException {
        return objectMapper.readValue(source, clazz);
    }
}


问:
Is there a way to add a second y axis to a matplotlib subplot?
(I think) I know about the twiny/x function in matplotlib, but I am really struggling to figure out how to use this function in a subplot context. I have a line plot like this showing rainfall data:

Generated by this code:

```<code>fig,ax = plt.subplots(3, figsize=(10,15),sharey=True)

ax[0].plot(YEAR1['pcp_1D_tot'], label='RG')
ax[0].plot(YEAR1['ppt_1D'], label='TRMM')
ax[0].set_title('Year 1',x=0.1,y=0.9)

ax[1].plot(YEAR2['pcp_1D_tot'], label='RG')
ax[1].plot(YEAR2['ppt_1D'], label='TRMM')
ax[1].set_title('Year 2',x=0.1,y=0.9)
ax[1].set_ylabel('Rainfall total (mm/day)')

ax[2].plot(YEAR3['pcp_1D_tot'], label='RG')
ax[2].plot(YEAR3['ppt_1D'], label='TRMM')
ax[2].set_title('Year 3',x=0.1,y=0.9)
ax[2].set_xlabel('Date')

fig.legend(loc=(0.8,0.9))
fig.tight_layout()
plt.show()
</code>```

But I also have data on flood magnitude I would like to add which is in categories of 1, 2, and 3, stored in a column named, e.g.

```<code>YEAR1['Size']
</code>```

I'd like to plot these as a scatter plot on top of the line plot to show their incidence relative to rainfall, and so I believe I need to add another y axis on the right, but I am very unclear how to do this.

Can anyone help?

**###########UPDATE############### **

Thanks to the contributions below, I managed to make the following, which is exactly what I was hoping for:

By using the following code:

```<code>x = YEAR1m.index #### these are referring to other data that has been filtered
y = YEAR2m.index
z = YEAR3m.index

fig,ax = plt.subplots(3, figsize=(10,15),sharey=True)

ax[0].plot(YEAR1['pcp_1D_tot'], label='RG')
ax[0].plot(YEAR1['ppt_1D'], label='TRMM')
ax[0].set_title('Year 1',x=0.1,y=0.9)
ax0 = ax[0].twinx()
ax0.scatter(x, YEAR1m['Size'], marker='*', color='r',s=100)
ax0.set_ylim([0,3.2])
ax0.set_yticklabels(['0',' ','1',' ','2',' ','3'])

ax[1].plot(YEAR2['pcp_1D_tot'], label='RG')
ax[1].plot(YEAR2['ppt_1D'], label='TRMM')
ax[1].set_title('Year 2',x=0.1,y=0.9)
ax[1].set_ylabel('Rainfall total (mm/day)')
ax1 = ax[1].twinx()
ax1.scatter(y, YEAR2m['Size'], marker='*', color='r',s=100)
ax1.set_ylim([0,3.2])
ax1.set_yticklabels(['0',' ','1',' ','2',' ','3'])

ax[2].plot(YEAR3['pcp_1D_tot'], label='RG')
ax[2].plot(YEAR3['ppt_1D'], label='TRMM')
ax[2].set_title('Year 3',x=0.1,y=0.9)
ax[2].set_xlabel('Date')
ax2 = ax[2].twinx()
ax2.scatter(z, YEAR3m['Size'], marker='*', color='r',s=100)
ax2.set_ylim([0,3.2])
ax2.set_yticklabels(['0',' ','1',' ','2',' ','3'])

# fig.legend(loc=(0.8,0.9))
fig.tight_layout()
plt.show()
</code>```

答:
I have not your data, let's see if I understood your problem...

Usual stuff,

```<code>import matplotlib.pyplot as plt
import numpy as np
</code>```

Generate some data

```<code>x = np.linspace(0, 1.57, 21)
y = np.sin(x)
z = 4*np.random.random(21)
</code>```

Prepare the figure with two subplots — I'm going to use only the first one to avoid have you bored — add a parasitic axes not to the current plot but to a specific axes

```<code>fig, (ax0, ax1) = plt.subplots(2, 1)
ax01 = ax0.twinx()
</code>```

Plot the curve(s), plot the scatter points using different colors (this is not dealt with automatically)

```<code>ax0.plot(x, y, color='blue')
ax01.scatter(x, z, color='red')
</code>```

This is a bit of an unrequested final touch... (note, it's colors, not color)

```<code>ax0.tick_params(axis='y',  colors='blue')
ax01.tick_params(axis='y', colors='red')
</code>```

and finally plt.show() gives us

I'd like to add: thank you Rutger Kassies for your fine answer, where the reader of my answer can find further advice on customizing all the details of the two vertical spines.

Body:
(I think) I know about the twiny/x function in matplotlib, but I am really struggling to figure out how to use this function in a subplot context. I have a line plot like this showing rainfall data:

Generated by this code:

fig,ax = plt.subplots(3, figsize=(10,15),sharey=True)

ax[0].plot(YEAR1['pcp_1D_tot'], label='RG')
ax[0].plot(YEAR1['ppt_1D'], label='TRMM')
ax[0].set_title('Year 1',x=0.1,y=0.9)

ax[1].plot(YEAR2['pcp_1D_tot'], label='RG')
ax[1].plot(YEAR2['ppt_1D'], label='TRMM')
ax[1].set_title('Year 2',x=0.1,y=0.9)
ax[1].set_ylabel('Rainfall total (mm/day)')

ax[2].plot(YEAR3['pcp_1D_tot'], label='RG')
ax[2].plot(YEAR3['ppt_1D'], label='TRMM')
ax[2].set_title('Year 3',x=0.1,y=0.9)
ax[2].set_xlabel('Date')

fig.legend(loc=(0.8,0.9))
fig.tight_layout()
plt.show()

But I also have data on flood magnitude I would like to add which is in categories of 1, 2, and 3, stored in a column named, e.g.

YEAR1['Size']

I'd like to plot these as a scatter plot on top of the line plot to show their incidence relative to rainfall, and so I believe I need to add another y axis on the right, but I am very unclear how to do this.

Can anyone help?

**###########UPDATE############### **

Thanks to the contributions below, I managed to make the following, which is exactly what I was hoping for:

By using the following code:

x = YEAR1m.index #### these are referring to other data that has been filtered
y = YEAR2m.index
z = YEAR3m.index

fig,ax = plt.subplots(3, figsize=(10,15),sharey=True)

ax[0].plot(YEAR1['pcp_1D_tot'], label='RG')
ax[0].plot(YEAR1['ppt_1D'], label='TRMM')
ax[0].set_title('Year 1',x=0.1,y=0.9)
ax0 = ax[0].twinx()
ax0.scatter(x, YEAR1m['Size'], marker='*', color='r',s=100)
ax0.set_ylim([0,3.2])
ax0.set_yticklabels(['0',' ','1',' ','2',' ','3'])

ax[1].plot(YEAR2['pcp_1D_tot'], label='RG')
ax[1].plot(YEAR2['ppt_1D'], label='TRMM')
ax[1].set_title('Year 2',x=0.1,y=0.9)
ax[1].set_ylabel('Rainfall total (mm/day)')
ax1 = ax[1].twinx()
ax1.scatter(y, YEAR2m['Size'], marker='*', color='r',s=100)
ax1.set_ylim([0,3.2])
ax1.set_yticklabels(['0',' ','1',' ','2',' ','3'])

ax[2].plot(YEAR3['pcp_1D_tot'], label='RG')
ax[2].plot(YEAR3['ppt_1D'], label='TRMM')
ax[2].set_title('Year 3',x=0.1,y=0.9)
ax[2].set_xlabel('Date')
ax2 = ax[2].twinx()
ax2.scatter(z, YEAR3m['Size'], marker='*', color='r',s=100)
ax2.set_ylim([0,3.2])
ax2.set_yticklabels(['0',' ','1',' ','2',' ','3'])

# fig.legend(loc=(0.8,0.9))
fig.tight_layout()
plt.show()

Body:
I have not your data, let's see if I understood your problem...

Usual stuff,

import matplotlib.pyplot as plt
import numpy as np

Generate some data

x = np.linspace(0, 1.57, 21)
y = np.sin(x)
z = 4*np.random.random(21)

Prepare the figure with two subplots — I'm going to use only the first one to avoid have you bored — add a parasitic axes not to the current plot but to a specific axes

fig, (ax0, ax1) = plt.subplots(2, 1)
ax01 = ax0.twinx()

Plot the curve(s), plot the scatter points using different colors (this is not dealt with automatically)

ax0.plot(x, y, color='blue')
ax01.scatter(x, z, color='red')

This is a bit of an unrequested final touch... (note, it's colors, not color)

ax0.tick_params(axis='y',  colors='blue')
ax01.tick_params(axis='y', colors='red')

and finally plt.show() gives us

I'd like to add: thank you Rutger Kassies for your fine answer, where the reader of my answer can find further advice on customizing all the details of the two vertical spines.


问:
Get the referrer, paid/natural and keywords for the current visitor with Google Analytics
Is it possible to get the following information about the current visitor using Google Analytics API with JavaScript?

Referrer site ('Source' in GA)

Paid or natural ('Medium' in GA)

Keyword

First time/returning

Number of visits

If it's not possible with Google Analytics API is there any other easy way to do it (apart from parsing HTTP Referer, storing the visits statistics in DB etc.)?

答: You should be able to get it all from the cookies set by Google Analytics. They are stored as first party cookies so JavaScript running on a page will be able to read them. The number of visits can be obtained from the last part of the __utma cookie and the referrer can be taken from __utmz. The source is the utmcsr bit of __utmz while the medium comes from utmcmd and the keyword is utmctr.