supervisor守护进程

有时候写个脚本跑着跑着挂了,用supervisor守护进程挺方便的。
Supervisor是一个Python开发的client/server系统,可以通过pip安装,需要注意的是Python2.7以下兼容性很差,很可能运行失败。

pip install Supervisor 

安装好后

echo_supervisord_conf > /etc/supervisord.conf 

生成配置文件
然后我们在配置文件末尾追加想守护的进程即可,写法如下

[program:program-name]
command = python /root/program-dir/program-name.py 
user = root  
autostart = true  
autorestart = true  

配置好后可以执行supervisord启动,也可以killall -HUP supervisord
再然后我们添加supervisord到系统服务中
下面是Centos 示例代码

#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/init.d/functions

RETVAL=0
prog="supervisord"
pidfile="/tmp/supervisord.pid"
lockfile="/var/lock/subsys/supervisord"

start()
{
        echo -n $"Starting $prog: "
        daemon --pidfile $pidfile supervisord -c /etc/supervisord.conf
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch ${lockfile}
}

stop()
{
        echo -n $"Shutting down $prog: "
        killproc -p ${pidfile} /usr/bin/supervisord
        RETVAL=$?
        echo
        if [ $RETVAL -eq 0 ] ; then
                rm -f ${lockfile} ${pidfile}
        fi
}

case "$1" in

  start)
    start
  ;;

  stop)
    stop
  ;;

  status)
        status $prog
  ;;

  restart)
    stop
    start
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|status}"

放在/etc/rc.d/init.d/supervisord 目录中,设置好执行权限后 我们chkconfig supervisord on 设置开机启动即可
简单吧!

Mac配置PyQt

Mac OS X 配置 PyQt

配置过程略繁琐,首先要安装qmake 然后安装sip  然后安装PyQt4/PyQt5 再然后想安装Eric的话需要安装QScintilla2
1.安装qmake
去http://www.qt.io/download-open-source/ 下载Qt安装包,License 选择GNU 不然后面没发安装PyQt

安装好后配置环境变量

[code]
export PATH="/Users/lvxinwei/Qt/5.5/clang_64/bin:$PATH"
[/code]

写在 .bash_profile 然后source .bash_profile
然后运行qmake看下是否成功了
2.下面安装sip
下载好sip后

[code]
python configure.py
make
sudo make install
[/code]

3.安装PyQt

[code]
python configure.py -d /Library/Python/2.7/site-packages/ –sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
make
sudo make install
[/code]

4.安装QScintilla2
先进入Qt4Qt5 然后

[code]
qmake qscintilla.pro -spec macx-g++
make
sudo make install
[/code]

再进入Python目录

[code]
python configure.py –sip /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip
[/code]

再然后进去designer-Qt4Qt5 目录

[code]
qmake designer.pro -spec macx-g++
make
sudo make install
[/code]

完成

iptable配置

[shell]

iptables   -A   OUTPUT   -d  wlt.ustc.edu.cn    -j   REJECT

[/shell]

1.创建/etc/iptables文件(文件名可以随意取)

2.创建/etc/network/if-pre-up.d/iptables文件,并给予其执行权限
root@godontop:~# touch /etc/network/if-pre-up.d/iptables
root@godontop:~# chmod +x /etc/network/if-pre-up.d/iptables
3.编辑/etc/network/if-pre-up.d/iptables文件,使其内容如下:
#!/bin/sh
/sbin/iptables-restore < /etc/iptables
4.配置iptables,过程略,配置好iptables后,将配置保存到/etc/iptables文件中即可
root@godontop:~# iptables-save > /etc/iptables

编译linux内核(Ubuntu 环境下)

1.配置

[code]
make menuconfig
[/code]

2.编译内核

[code]

make

[/code]

3.安装模块
[code]

make modules_install
[/code]

模块被安装到 /lib/modules/2.6.33.1目录下

4.安装内核二进制映象文件

[code]

make install

[/code]

因为笔者使用的是ubuntu系统,需要执行以下的命令才能生成和安装boot初始化文件系统映象
[code]

update-initramfs -c -k 2.6.33.1

[/code]

5.在一些系统设置下,可能需要手动进行grub设置才能从当前安装的内核启动。在这种情况下下,请适当编辑/boot/grub/menu.lst或是
执行

[code]

update-grub2

[/code]

6.重新启动系统
7.查看系统内核
[code]

uname -r

[/code]