当前位置:网站首页>NJS triggers system command operation
NJS triggers system command operation
2022-06-24 01:16:00 【Huangxitong】
NginScript There is no ability to directly invoke operating system commands for the time being , But with fs Object can manipulate the local file system , When local commands need to be triggered, messages can be delivered through the file system , Such as this :
function execCommand(cmd){
var fs = require('fs');
var path;
if(cmd == "start") path='/dev/shm/start-command';
if(cmd == "stop") path='/dev/shm/stop-command';
var file = fs.writeFileSync(path, '');
}
When you need to operate, it is on the memory disk /dev/shm Write an empty file ( Overwrite if it already exists ), The file name is the name of the command you started .
Install a file monitoring tool
yum install inotify-tools -y
#!/bin/bash
inotifywait -m -e open /dev/shm/ |
while read events;
do
if [ "$events" == "/dev/shm/ OPEN start-command" ]; then
echo 'start command';
do-something-to-start-service;
fi
if [ "$events" == "/dev/shm/ OPEN stop-command" ]; then
echo 'stop command';
do-something-to-stop-service;
fi
doneNo technical content . It is not beautiful to realize this through the file system , Make do with .
边栏推荐
- Forward design of business application data technology architecture
- Version ` zlib 1.2.9 "not found (required by / lib64 / libpng16.so.16)
- 7 tips for preventing DDoS Attacks
- 杂乱的知识点
- Isn't this another go bug?
- [applet] realize the effect of double column commodities
- Relationship between continuous testing and quality assurance
- Talk to Wu Jiesheng, head of Alibaba cloud storage: my 20 years of data storage (unlimited growth)
- version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
- Attack and defense world PyC trade
猜你喜欢

CVPR2022 | 可精简域适应

所见之处都是我精准定位的范畴!显著图可视化新方法开源

用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧

Efficient integration of heterogeneous single cell transcriptome with scanorama

分别用SVM、贝叶斯分类、二叉树、CNN实现手写数字识别

Cvpr2022 𞓜 thin domain adaptation

Kitten paw: FOC control 15-mras method of PMSM

13 `bs_duixiang.tag标签`得到一个tag对象
![[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.](/img/3f/988ed31a3f1cdc92deed121ed8d4ec.png)
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.

Use recursion to form a multi-level directory tree structure, with possibly the most detailed notes of the whole network.
随机推荐
【Redis进阶之ZipList】如果再有人问你什么是压缩列表?请把这篇文章直接甩给他。
[technical grass planting] take you to Tencent cloud's private cloud disk in ten minutes
Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)
Experience summary of 9 Android interviews, bytes received, Ali, advanced Android interview answer
How to build a "preemptive" remote control system (- - memory chapter)
Social recruitment interview is indispensable -- 1000 interview questions for Android engineers from Internet companies
ShardingSphere-proxy-5.0.0容量范围分片的实现(五)
Definition of logic
13 `bs_duixiang.tag标签`得到一个tag对象
CVPR2022 | 可精简域适应
Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training
Is it safe to open a stock account online now? Select a state-owned securities firm, and the fastest time to open an account is 8 minutes
[Hongke case] how can 3D data become operable information Object detection and tracking
Sockfwd a data forwarding gadget
Leetcode lecture on algorithm interview for large factories 2 Time space complexity
Grab startup logcat
Map design
Isn't this another go bug?
985 Android programmers won the oral offer of Alibaba P6 in 40 days. After the successful interview, they sorted out these interview ideas
Common core resource objects of kubernetes