<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=LUA_NGINX_Examples</id>
	<title>LUA NGINX Examples - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=LUA_NGINX_Examples"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=LUA_NGINX_Examples&amp;action=history"/>
	<updated>2026-04-24T09:36:32Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=LUA_NGINX_Examples&amp;diff=210&amp;oldid=prev</id>
		<title>imported&gt;Jeremy-busk at 18:29, 5 June 2019</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=LUA_NGINX_Examples&amp;diff=210&amp;oldid=prev"/>
		<updated>2019-06-05T18:29:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;```&lt;br /&gt;
location = /healthcheck {&lt;br /&gt;
&lt;br /&gt;
    content_by_lua_block {&lt;br /&gt;
        local redis = require &amp;quot;resty.redis&amp;quot;&lt;br /&gt;
        local red = redis:new()&lt;br /&gt;
        red:set_timeout(1000)&lt;br /&gt;
        local ok, err = red:connect(&amp;quot;127.0.0.1&amp;quot;, 6379)&lt;br /&gt;
        if not ok then&lt;br /&gt;
            ngx.status = 500&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        local ps = io.popen(&amp;quot;/bin/ps aux &amp;gt;/tmp/ps.out&amp;quot;, &amp;quot;w&amp;quot;)&lt;br /&gt;
        ps:close()&lt;br /&gt;
        local ps = io.popen(&amp;quot;grep -c '[j]ava.*63' /tmp/ps.out&amp;quot;)&lt;br /&gt;
        local output = tostring(ps:read())&lt;br /&gt;
        ps:close()&lt;br /&gt;
        if string.match(output, '4') then&lt;br /&gt;
            ngx.status = 200&lt;br /&gt;
        else&lt;br /&gt;
            ngx.status = 500&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
 f = assert (io.popen (&amp;quot;ls -l&amp;quot;))&lt;br /&gt;
  &lt;br /&gt;
 for line in f:lines() do&lt;br /&gt;
   print(line)&lt;br /&gt;
 end -- for loop&lt;br /&gt;
   &lt;br /&gt;
 f:close()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An alternative to using pipes, if you want to capture operating system output, is to redirect command output to a temporary file, like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-- get a temporary file name&lt;br /&gt;
n = os.tmpname ()&lt;br /&gt;
&lt;br /&gt;
-- execute a command&lt;br /&gt;
os.execute (&amp;quot;dir &amp;gt; &amp;quot; .. n)&lt;br /&gt;
&lt;br /&gt;
-- display output&lt;br /&gt;
for line in io.lines (n) do&lt;br /&gt;
  print (line)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- remove temporary file&lt;br /&gt;
os.remove (n)&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>imported&gt;Jeremy-busk</name></author>
	</entry>
</feed>