Ghost blogging platform installation instructions[license:CC-BY-3.0]中有一节介绍了如何使用supervord来部署一个nodejs脚本(运行blog),以便它在失败时和系统重新启动时重新启动。在Supervisor (http://supervisord.org/) Popular Linux distributions—such

as Fedora, Debian, and Ubuntu—maintain a package for Supervisor: A

process control system which allows you to run Ghost at startup

without using init scripts. Unlike an init script, Supervisor is

portable between Linux distributions and versions.

Install Supervisor as required for your Linux distribution. Typically,

this will be:

Debian/Ubuntu: apt-get install supervisor

Fedora: yum install supervisor

Most other distributions: easy_install supervisor

Ensure that Supervisor is running, by running

service supervisor start

Create the startup script for your Ghost installation. Typically this will go

in

/etc/supervisor/conf.d/ghost.conf

For example:[program:ghost]

command = node /path/to/ghost/index.js

directory = /path/to/ghost

user = ghost

autostart = true

autorestart = true

stdout_logfile = /var/log/supervisor/ghost.log

stderr_logfile = /var/log/supervisor/ghost_err.log

environment = NODE_ENV="production"Start Ghost using Supervisor: supervisorctl start ghost

To stop Ghost: supervisorctl stop ghost

好的,那么如果您的脚本名为myscript.py,它属于usersnake并且位于/home/snake。在

那么命令应该是python /home/snake/myscript.py,目录应该在您想运行它的任何地方(我们假设这是/home/snake),应该适当地设置用户(我们假设您希望以usersnake身份运行),自动保持不变,并且应该重命名日志文件。在

环境设置脚本所需的任何ENV变量。通常情况下,除非使用它们来控制脚本的各个方面,否则您不需要它们。在如上所述安装监督员,但不要为幽灵设置任何东西

相反,创建/etc/supervisor/conf.d/myscript,如下所示:

myscript管理程序

/etc/supervisor/conf.d/myscript

^{pr2}$

应该正在运行,即使重新启动也会重新启动。在

关于你的安全问题,这是有问题的。如果假定攻击者对包含脚本的文件系统具有读/写访问权限,则他们还可以更改安全哈希。公钥签名要好一点,因为攻击者不知道要将签名更改为什么,因为他缺少私钥。但同样,攻击者可能只是重写测试签名的代码并绕过它,或者在验证后替换脚本以运行脚本,从而始终运行其他命令。在

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐