当前位置:网站首页>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 .
边栏推荐
- . Net core cross platform development bbs forum (connotation source code + complete operation video)
- 2022 postgraduate entrance examination experience sharing [preliminary examination, school selection, re examination, adjustment, school recruitment and social recruitment]
- 7 tips for preventing DDoS Attacks
- Dart series part: asynchronous programming in dart
- 【CVPR 2020 Oral】极低光去噪论文:A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
- Niu Xuechang's anniversary celebration: software promotion, limited time and free registration code!
- 13 `bs_ duixiang. Tag tag ` get a tag object
- Alibaba interview question: multi thread related
- Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
- Perhaps the greatest romance of programmers is to commemorate their dead mother with a software
猜你喜欢
![Graduation project - thesis writing notes [design topic type, thesis writing details, design materials]](/img/66/c0c400609b56dd012d87c620ca66e4.png)
Graduation project - thesis writing notes [design topic type, thesis writing details, design materials]

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

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

985 Android programmers won the oral offer of Alibaba P6 in 40 days. After the successful interview, they sorted out these interview ideas

Error reported using worker: uncaught domexception: failed to construct 'worker': script at***
![[applet] realize the effect of double column commodities](/img/e3/b72955c1ae67ec124520ca46c22773.png)
[applet] realize the effect of double column commodities

Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
![[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection](/img/79/7dfc30565ddee0769ef5f1bc239b5d.png)
[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection

LSF打开Job idle information以看job的cpu time/elapse time使用情况

CVPR2022 | 可精简域适应
随机推荐
Kubernetes' ci/cd practice based on Jenkins spinnaker - adding product image scanning
[applet] realize the effect of double column commodities
Messy knowledge points
[technology planting grass] talk about the system design and architecture of large-scale shopping platform
Solve the problem that Base64 compressed files are extracted with spaces after post request
LSF opens job idle information to view the CPU time/elapse time usage of the job
Dart series part: asynchronous programming in dart
Definition of logic
ShardingSphere-proxy-5.0.0容量范围分片的实现(五)
LSF打开Job idle information以看job的cpu time/elapse time使用情况
[CVPR 2020 oral] a physics based noise formation model for extreme low light raw denoising
分别用SVM、贝叶斯分类、二叉树、CNN实现手写数字识别
Architecture solutions
DML操作
阿里巴巴面试题:多线程相关
Map design
How to open Tencent enterprise mailbox and Tencent enterprise mailbox login portal
CODING CD
skywalking 安装部署实践
Talk to Wu Jiesheng, head of Alibaba cloud storage: my 20 years of data storage (unlimited growth)