Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

单个 process 直接执行 ✅ vs && 多个 process ❌ #5

Open
xgqfrms opened this issue Oct 14, 2021 · 3 comments
Open

单个 process 直接执行 ✅ vs && 多个 process ❌ #5

xgqfrms opened this issue Oct 14, 2021 · 3 comments
Labels
Linux bash & vs && Linux bash & vs && 并行 & 串行 并行 & 串行

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented Oct 14, 2021

单个 process 直接执行 ✅ vs && 多个 process ❌

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented Oct 14, 2021

git diff

d4c6bcb

demos

# 单个 process 直接执行 ✅
$ PORT_ENV=999 node ./bug.js
# process.env.PORT_ENV = 999


# && 多个 process ❌
$ PORT_ENV=999 && node ./bug.js
# process.env.PORT_ENV = undefined
# 系统临时变量,分布执行  
$ export PORT_ENV=999
$ node ./bug.js
# process.env.PORT_ENV = 999

bug.js

console.log('\n process.env.PORT_ENV =', process.env.PORT_ENV);

// console.log('\n PORT_ENV =', process.env.PORT_ENV);

@xgqfrms
Copy link
Owner Author

xgqfrms commented Oct 15, 2021

solution

env.js

module.exports = process.env.PORT_ENV || 8080;

env-test.js

const PORT_ENV = require('./env.js');

console.log('PORT_ENV =', PORT_ENV);
console.log('process.env.PORT_ENV =', process.env.PORT_ENV);

testing OK ✅

# 单个 process 直接执行 ✅

$ PORT_ENV=777 node ./env-test.js

xgqfrms/app-node-env@74c4073

@xgqfrms
Copy link
Owner Author

xgqfrms commented Apr 12, 2022

Linux bash & vs &&

并行 & 串行

image

https://www.cnblogs.com/xgqfrms/p/16137768.html

@xgqfrms xgqfrms added 并行 & 串行 并行 & 串行 Linux bash & vs && Linux bash & vs && labels Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux bash & vs && Linux bash & vs && 并行 & 串行 并行 & 串行
Projects
None yet
Development

No branches or pull requests

1 participant