修改正在运行的脚本,并让它重新加载,而不杀死它(PHP) [英] Modifying a running script and having it reload without killing it (php)

查看:305
本文介绍了修改正在运行的脚本,并让它重新加载,而不杀死它(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Debian运行的游戏服务器,玩家可以通过网络编辑(已运行)的PHP脚本修改游戏。然而,一旦更改对脚本进行并保存,牵动一旦脚本被杀害并重新启动的变化只发生(我要在终端手动执行此操作)。没有给用户shell访问,剧本怎么能知道重新加载自身的新版本,一旦修改过?该脚本在GNU屏幕上运行。

I have a gameserver running on Debian where players can edit an (already-running) php script via web to modify the game. However, once changes are made to the script and saved, the affects of the changes only happen once the script is killed and rebooted (I have to do this manually in terminal). Without giving shell access to users, how can the script know to reload a new version of itself once changes have been made? The script is running in a GNU Screen.

虽然我的GNU屏幕,PHP和Linux命令对整体的知识是有限的,我觉得必须有这个做的一种方式。

Although my overall knowledge on GNU screen, php, and linux commands are limited, I think there has to be a way for this to be done.

什么会最简单的方法是什么?

What would the easiest way be?

修改
为了澄清,那人修改剧本是一个基本的脚本,通常读取服务器输出日志。所以,当看到剧本PLAYER_DIED写入到文件,而这又是由服务器读取并执行一些东西,像产卵区。
人们现在与链接到PHP源$ C ​​$ C基本的基于Web的文本编辑器编辑该脚本

EDIT To clarify, the script that people modify is a basic script that usually reads a server output log. So when the script sees "PLAYER_DIED" it writes to a file, which in turn is read by the server and does some stuff, like spawn a zone. People edit this script right now with a basic web-based text editor linked to the php source code

推荐答案

有多种方式来实现这一点,但很难说哪种方法是最好的,因为你不共享任何源$ C ​​$ C的。

There are numerous ways to achieve this, but it's hard to tell which method is the best since you don't share any of your source code.

为什么同一个脚本内不能重新启动它,你用它来让玩家修改剧本?

Why not restart it within the same script that you use to let the players modify the script?

另一个解决方案是有一个小的cron脚本运行每分钟检查文件是否被更改。如果是的话它就会重新启动实例。在最坏的情况下,球员们必须等待一分钟,直到变化被认为。

Another solution is to have a small cron-script that runs every minute to check if the file was changed. If so it will then restart the instance. In a worst case scenario, the players have to wait a minute until the changes are seen.

另外我,如果你正在使用某种形式的运行由玩家编辑或如果您直接运行该脚本的实际脚本守护进程的疑惑。

Also I'm wondering if you are using some kind of deamon that is running the actual script that is edited by the players or if you are running that script directly.

这篇关于修改正在运行的脚本,并让它重新加载,而不杀死它(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆