aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2010-04-13 00:00:20 +0200
committerLaurent Bachelier <laurent@bachelier.name>2010-04-13 00:00:20 +0200
commit17d67a80c08b8220124983f6a86799634215b6d6 (patch)
treec59ddc7aa97683c69fc0d90683b428d04a01459e
parentDocumentation updates (diff)
downloadsymfttpd-17d67a80c08b8220124983f6a86799634215b6d6.tar.xz
Adds the ability to kill the current spawned symfttpd
-rw-r--r--README.md10
-rw-r--r--data/lighttpd.conf.php2
-rwxr-xr-xspawn19
3 files changed, 30 insertions, 1 deletions
diff --git a/README.md b/README.md
index 0c42728..33d810b 100644
--- a/README.md
+++ b/README.md
@@ -220,3 +220,13 @@ Yes.
No!
+### Can I start spawn in the background?
+
+Yes, just add `&` after your command.
+
+ /path/to/symfttpd/spawn &
+
+To stop a running symfttpd (backgrounding or not), just run:
+
+ /path/to/symfttpd/spawn --kill &
+
diff --git a/data/lighttpd.conf.php b/data/lighttpd.conf.php
index 6ad58cb..e27b0bc 100644
--- a/data/lighttpd.conf.php
+++ b/data/lighttpd.conf.php
@@ -37,7 +37,7 @@ static-file.exclude-extensions = (".php")
# http://redmine.lighttpd.net/issues/406
server.force-lowercase-filenames = "disable"
-server.pid-file = "<?php echo $config_dir ?>/lighttpd.pid"
+server.pid-file = "<?php echo $pidfile ?>"
server.errorlog = "<?php echo $log_dir ?>/error.log"
accesslog.filename = "<?php echo $log_dir ?>/access.log"
diff --git a/spawn b/spawn
index 0a5966b..4e520f7 100755
--- a/spawn
+++ b/spawn
@@ -23,6 +23,24 @@ $options['bind'] = Argument::get('A', 'all', false)
$options['project_path'] = $project_path;
$options['config_dir'] = $project_path.'/cache/lighttpd';
$options['log_dir'] = $project_path.'/log/lighttpd';
+// hack: .sf files are not removed by symfony cc
+$options['pidfile'] = $options['config_dir'].'/.sf';
+
+if (Argument::get('K', 'kill', false))
+{
+ if (file_exists($options['pidfile']))
+ {
+ $pid = trim(file_get_contents($options['pidfile']));
+ posix_kill($pid, SIGTERM);
+ echo 'Process '.$pid." killed\n";
+ exit(0);
+ }
+ else
+ {
+ echo "No running process found\n";
+ exit(1);
+ }
+}
FileTools::mkdirs($options['config_dir']);
FileTools::mkdirs($options['log_dir']);
@@ -89,3 +107,4 @@ flush();
passthru($options['lighttpd_cmd'].' -D -f '.escapeshellarg($config_file));
+echo "Terminated\n";