/etc/init.d/nginx (lsb style)

这几天学习了一下heartbeat的资料,想参照 Two Apache Web Servers in an Active/Active Configuration    做个Two Nginx Web Services in Active/Active HA。研究发现,heartbeat所管理的资源代理(Resource Agent),有OCF、LSB等几种 。LSB这种shell脚本我还能依葫芦画瓢的写一点,参考linux系统中的原有脚本和网上资料,写了一个很简单的:

 

#!/bin/bash
#
# nginx:       Control the nginx Daemon
#
# Version:      @(#) /etc/init.d/nginx 0.1
#
# description: This is a init.d script for nginx. Tested on CentOS4. \
#              Change DAEMON and PIDFILE if neccessary.
#

#Location of nginx binary. Change path as neccessary
DAEMON=/usr/local/nginx/sbin/nginx
NAME=`basename $DAEMON`

#Pid file of nginx, should be matched with pid directive in nginx config file.
PIDFILE=/var/run/$NAME.pid

#this file location
SCRIPTNAME=/etc/init.d/$NAME

#only run if binary can be found
test -x $DAEMON || exit 0

RETVAL=0

start() {
	echo $"Starting $NAME"
	$DAEMON
	RETVAL=0
}

stop() {
	echo $"Graceful stopping $NAME"
	[ -s "$PIDFILE" ] && kill -QUIT `cat $PIDFILE`
	RETVAL=0
}

forcestop() {
    echo $"Quick stopping $NAME"
    [ -s "$PIDFILE" ] && kill -TERM `cat $PIDFILE`
    RETVAL=$?
}

reload() {
    echo $"Graceful reloading $NAME configuration"
    [ -s "$PIDFILE" ] && kill -HUP `cat $PIDFILE`
    RETVAL=$?
}

status() {
    if [ -s $PIDFILE ]; then
        echo $"$NAME is running."
        RETVAL=0
    else
        echo $"$NAME stopped."
        RETVAL=3
    fi
}
# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    force-stop)
        forcestop
        ;;
    restart)
        stop
        start
        ;;
    reload)
        reload
        ;;
    status)
        status
        ;;
    *)
        echo $"Usage: $0 {start|stop|force-stop|restart|reload|status}"
        exit 1
esac

exit $RETVAL

注意对应的Nginx配置的PID指令。

参考资料:

LSBResourceAgent

Running and Controlling Nginx

Boot Script for Nginx on Ubuntu, Debian etc.
Debian 7下Nginx Server Blocks配置实战与安全隔离 虚拟主机(Virtual Host)是Web服务器实现多站点共存的基础机制,其核心原理在于基于请求头或IP端口的路由分发与上下文隔离。在Nginx中,这一能力由Server Blocks提供,它通过server_name、listen指令和精确的location匹配规则,在配置加载阶段完成静态路由绑定,具备低开销、高确定性和强安全边界的技术价值。广泛应用于老旧系统运维、边缘计算节点、教育实验平台及工业HMI托管等资源受限但稳定性要求高的场景。本文聚焦Debian 7(Wheezy)这一长期服役的发行版,深入 阅读详情

相关推荐

Nginx通过/etc/init.d/nginx方式启停【nginx配置文件】

vi /etc/init.d/nginx 修改nginx后 chmod +x /etc/init.d/nginx /sbin/chkconfig nginx on sudo /sbin/chkconfig --list nginx /etc/init.d/nginx start

linux centos 安装 NGINX方法及bug解决

linux centos 安装 NGINX方法及bug解决: 1、yum install gcc gcc-c++ make 2、下载:wget http://nginx.org/download/nginx-1.8.1.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip 3、解压:tar...

SmallWalnutBG的博客 559

Code Composer Studio 12.0.0版本 官方例程导入实战指南

本文详细介绍了在Code Composer Studio 12.0.0版本中,如何利用内置的Resource Explorer工具高效导入官方例程的完整实战指南。通过分步讲解定位开发板、导入工程、配置编译器及调试验证等关键操作,帮助开发者快速上手TI微控制器开发,避免常见错误,有效提升学习与开发效率。

weixin_29169899的博客 129

启动service提示:log_daemon_msg: command not found

要启动一个第三方app的服务,服务启动脚步有一行如下: . /lib/lsb/init-functions 发现这个没有安装,执行 yum -y install lsb 后有这个脚本了。 然后再启动还是提示:log_daemon_msg: command not found 网上查了下,说 lsb 的 init-functions脚本不适合redhat的服务器。 另外,居然发现bash没有安装,服务启动脚本开头指定用bash。 yum -y install redhat-lsb-core yum -y in

WEI的博客 1615

从网口变压器到TVS管:手把手设计通过4KV浪涌的以太网电路

本文详细解析工业级以太网接口4KV浪涌防护设计,从网口变压器选型到TVS管布局,提供通过IEC61000-4-5标准测试的完整方案。重点介绍Bob Smith电路优化和PCB设计技巧,帮助工程师有效应对雷电感应和设备开关瞬态干扰,确保工业设备稳定运行。

study的专栏 305

微信小程序-如何根据缩放屏幕大小自适应icon图标更改marker

微信小程序如何根据用户的缩放屏幕来改变marker图标icon的大小,实现icon自适应屏幕缩放的效果

Bartender_VA11的博客 3995

Nginx通过/etc/init.d/nginx方式启动或停止服务

Nginx 启动、重启、停止脚本 第一步 先运行命令关闭nginx sudo kill `cat /usr/local/nginx/logs/nginx.pid` 第二步 vi /etc/init.d/nginx 输入以下内容 : #!/bin/bash # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, H

太#阳%鸟的博客 4495

《深入浅出强化学习原理入门》学习笔记(三)机器人找金币应用实例

《深入浅出强化学习原理入门》学习笔记(三)MDP应用实例

lxs3213196的博客 3197

nginx启动、重启、关闭

方式一:传统方法 一、启动   cd usr/local/nginx/sbin ./nginx 二、重启   更改配置重启nginx   kill -HUP 主进程号或进程号文件路径 或者使用 cd /usr/local/nginx/sbin ./nginx -s reload     判断配置文件是否正确  nginx -t -c

弹指天下 14万+

Android 16(API 36)状态栏颜色适配全攻略:从沉浸式到自定义背景

本文全面解析Android 16(API 36)强制沉浸式状态栏带来的适配挑战,提供了从FrameLayout包裹法到动态修改Window背景色的核心解决方案。针对传统状态栏颜色设置失效问题,详细阐述了如何利用WindowInsets API实现自定义背景,并涵盖全屏模式、Fragment切换及第三方ROM兼容性等实战场景,为开发者提供一站式适配指南。

weixin_29227425的博客 603

[QMT和ptrade量化交易小白入门]-109、小市值选股的基础上用六脉神剑评分,回测年化可到132%

本专栏主要是介绍QMT和ptrade的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写200篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步。

木头大左的博客 1876

Nginx的安装和使用

Nginx的安装和使用 本文是基于WIndows 10和CentOS 7.3系统环境,进行Nginx的安装和使用 WIndows 10 Nginx-1.5.1 CentOS 7.3 一、nginx安装和配置(Windows 10) (1) 下载nginx安装包 Nginx-1.5.1 (2) 解压安装包,并进入安装包的目录 解压目录不要有中文,也不要有空格 (3) 修改配置文件 #us...

哈工大许政的博客 2万+

PCIe Link Training 深度解析:从物理检测到高速数据传输

本文深入解析PCIe链路训练(Link Training)的技术细节,揭示了这一复杂协商过程的五个关键阶段:物理检测阶段通过电气特性识别设备连接;轮询阶段建立时钟和符号同步;配置阶段确定链路宽度并处理拓扑异常;恢复阶段完成速率切换和信号均衡;最终进入正常工作状态。文章特别强调了高速率下的均衡技术挑战,以及验证工程师需要关注的多个维度,包括状态机跳转、有序集内容、均衡算法和错误恢复能力。随着PCIe速率不断提升,理解这一底层机制对高速接口设计具有重要价值。

元直的博客 1670

从源码到部署:Ground Control交叉编译与init.d服务配置完全手册

Ground Control是一款专为树莓派设计的Go语言监控管理工具,能够帮助用户轻松管理和监控树莓派设备。本文将详细介绍如何从源码交叉编译到部署配置的完整流程,让你快速掌握这个强大的树莓派管理工具。 ## 🚀 Ground Control项目概述 Ground Control是一个基于Go语言开发的轻量级守护进程,专门为树莓派优化设计。它提供了直观的Web界面,让你可以远程监控树莓派的健

gitblog_00166的博客 344

WinCC实现定时存储数据至SQLServer

环境 Win10 WinCC V7.5 SQL Server 2016 运行结果 流程 WinCC变量 全局VB脚本 (我设置的是每2秒存一次,因此周期性触发器设置1秒)

skr? 3995

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Pacemaker + Nginx实现高可用

一、实现高可用 1.server4主机配置nginx [root@server1 ~]# scp -r /usr/local/nginx/ server4:/usr/local [root@server4 ~]# ln -s /usr/local/nginx/sbin//nginx /sbin/ [root@server4 ~]# useradd nginx [root@server4 ~]#...

wwy0324的博客 967

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Ubuntu/Debian下可用的/etc/init.d/nginx文件

为什么80%的码农都做不了架构师?>>> ...

weixin_34406061的博客 370

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Nginx的安装

安装Nginx说明,提供编译安装,官方仓库安装,Docker安装说明

shijin741231的博客 1059

Debian 8下源码编译Nginx实战:解决TLS崩溃、模块缺失与SysVinit兼容问题

Nginx 是高性能 Web 服务器与反向代理的核心组件,其运行依赖 OpenSSL 协议栈、PCRE 正则引擎及系统服务管理机制。在老旧但仍在服役的 Debian 8(Jessie)环境中,官方 apt 包存在 OpenSSL 1.0.1t TLS 1.2 崩溃、HTTP/2 模块缺失、SysVinit 启动超时等生产级缺陷。本文聚焦于 Nginx 源码编译这一可控部署路径,详解如何绑定 OpenSSL 1.1.1w 实现 TLS 1.2/1.3 安全加固,通过定制 configure 参数启用 http

weixin_33748818的博客 330

Ubuntu 14.04 LTS 安装 Nginx 实战指南:APT 与源码编译双路径

Nginx 是高性能、事件驱动的 Web 服务器与反向代理,其核心依赖 epoll、sendfile 等 Linux 内核机制,具备低内存占用与高并发处理能力。在工业控制、电力调度、嵌入式网关等存量系统中,Ubuntu 14.04 LTS 因长期稳定性和 ESM 安全支持,仍是关键运行基线。本文聚焦真实生产约束下的 Nginx 部署——涵盖 old-releases 源迁移、libssl1.0.0 版本兼容、离线 deb 依赖闭环、nginx-full 包名识别等高频痛点,并对比 APT 快速部署与源码编译

weixin_34315485的博客 406

Linux下Nginx启动脚本

//系统 CentOS release 6.9 (Final) # cat /etc/init.d/nginx //脚本内容如下 # chmod +x /etc/init.d/nginx //需要添加执行权限 #!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.3 version. # chkcon...

Beta blog 1195

CentOS 7 Nginx 错误集合

Nginx 错误集合 1、$ env: /etc/init.d/nginx: 没有那个文件或目录 这个问题刚开始困惑了我很久,明明文件是存在的啊,脚本也没什么错啊,怎么就是说文件找不到,后面在网看到说是因为文件格式为doc,Linux不能识别,所以,我的做法是:把文件内容复制出来,然后把之前的/etc/init.d/nginx删除,用 vi /etc/init.d...

diaotukai8020的博客 540

OpenSuse下安装 jdk/mysql/tomcat/nginx/mysql-proxy

安装 tomcat a.去http://tomcat.apache.org下载最新版(tar.gz) b.解压到/usr/local/目录 下 c.加权限 #chmod a+x /usr/local/tomcat/bin/startup.sh #chmod a+x /usr/local/tomcat/bin/shutdown.sh #chmod a+x /usr/local/tomcat/bin/catalina.sh #chmod a+x /usr/local/tomcat/bin/setc

websph的专栏 1756

Nginx + Let‘s Encrypt 在 Ubuntu 上的可信部署实战

HTTPS 是现代 Web 服务的安全基石,其核心依赖于 SSL/TLS 证书的正确获取与配置。Let’s Encrypt 作为主流免费证书颁发机构,通过 ACME 协议实现自动化签发,但实际落地常受制于 Nginx 配置兼容性、Ubuntu 系统环境约束及证书续期可靠性等工程细节。理解 ALPN 协议支持、HTTP-01 挑战路径路由、文件权限模型与 systemd 运维闭环,是保障证书‘拿得到、配得稳、续得上’的关键。本文聚焦 Nginx 与 Let’s Encrypt 在 Ubuntu 平台的深度协同

chuange6363的博客 453

转到nginx,用上php-cgi了

nginx用来做fcgi服务器配置倒是非常方便。一个多月前曾用过lighttpd,但由于不大稳定,一直想换到nginx。nginx已经工作好几周都没有问题,于是准备将所有php开发的项目都转来。nginx好像配置更简洁,没有cgi概念,只服务于fcgi和静态页面。我喜欢。 fcgi需要php在后台运行。我用的是debian/ubuntu系,直接sudo apt-get install

空空的世界 6005

Ubuntu 18.04 部署 Nginx 完整实践指南

Nginx 是最主流的轻量级 Web 服务器与反向代理工具,其核心价值在于高性能、低资源占用和灵活的请求路由能力。工作原理基于事件驱动的异步非阻塞模型,通过 master-worker 架构实现高并发处理,配合配置文件的模块化设计(如 http、server、location 块)完成静态服务、负载均衡与 API 网关等关键任务。在 Linux 生产环境中,Nginx 部署不仅涉及二进制安装,更需协同 systemd 服务管理、ufw 防火墙策略及文件权限控制,形成端到端的运维闭环。典型应用场景包括前端单页

weixin_30906185的博客 373
上一篇: 老版本apache模拟2.2.5中出现的ProxyPassMatch
下一篇: heartbeat V2在CentOS4.6上简要安装、配置笔记
sorphi
博客等级 码龄24年 0粉丝 5原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值