{"id":18370313,"url":"https://github.com/travispaul/lua-simple-fcgi","last_synced_at":"2026-04-15T07:33:55.945Z","repository":{"id":33764378,"uuid":"37420010","full_name":"travispaul/lua-simple-fcgi","owner":"travispaul","description":"A simple FastCGI interface for writing stateful web applications in Lua.","archived":false,"fork":false,"pushed_at":"2015-12-27T03:38:11.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-28T19:40:01.703Z","etag":null,"topics":["fcgi","lua"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travispaul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-14T16:27:42.000Z","updated_at":"2021-01-13T16:16:25.000Z","dependencies_parsed_at":"2022-09-13T18:10:38.437Z","dependency_job_id":null,"html_url":"https://github.com/travispaul/lua-simple-fcgi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/travispaul/lua-simple-fcgi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travispaul%2Flua-simple-fcgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travispaul%2Flua-simple-fcgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travispaul%2Flua-simple-fcgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travispaul%2Flua-simple-fcgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travispaul","download_url":"https://codeload.github.com/travispaul/lua-simple-fcgi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travispaul%2Flua-simple-fcgi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31831842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fcgi","lua"],"created_at":"2024-11-05T23:38:31.150Z","updated_at":"2026-04-15T07:33:55.928Z","avatar_url":"https://github.com/travispaul.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lua-simple-fcgi\n\nA simple FastCGI interface for writing stateful web applications in Lua.\n\n## Usage\n\nCreate a lua script that returns a table with the following 4 functions.\nThe only required function is ```accept```.\n\n* [accept](#accept)\n* [start](#start)\n* [restart](#restart)\n* [stop](#stop)\n\n### accept\n\nThe `accept` function is called each time a request is made.\n\nYou must return a string with the correctly formatted headers and response body.\n\nThe `Status` header is particularly important, it is needed by the web server\nto return the correct response code and header.\n\nYou can access the REQUEST_URI, REQUEST_METHOD and other environment variables\nusing the `os.getenv` function.\n\nYou can never call `print` in the accept function, the FastCGI library owns\nstandard input, standard output, and standard error at this point. Calling\n`print` will cause standard out to close and your application will be unable to\nrespond to requests.\n\n```lua\n    function accept()\n        return \"Status: 200 Ok\\r\\n\" ..\n            \"Content-Type: text/html\\r\\n\\r\\n\" ..\n            \"\u003ch1\u003eHello!\u003c/h1\u003e\"\n    end\n```\n\n### start\n\nThe `start` function is called before the process starts accepting requests.\nThis is a good place to open database connections, parse config files or \nperform any other initialization tasks needed by your application.\n\nAny non-zero return value will be considered a failure and the process will exit\nwith the return code.\n\n```lua\n    function run()\n        -- do initialization stuff here...\n        return 0\n    end\n```\n\n### restart\n\nThe `restart` function is called any time a SIGHUP signal is sent to the spawned\nFastCGI process. You can use this function to reload configuration files,\nreconnect to databases or simply clear the state of the application.\n\n```lua\n    function restart()\n        -- Do stuff on restart here\n    end\n```\n\n### stop\n\nThe `stop` function is called any time a SIGTERM signal is sent to the spawned \nFastCGI process. It's a good time to flush any cached data or cleanly tear down\nconnections or open files.\n\nIf a non-zero return value is returned the process will not terminate.\n\u003csup\u003eFeature not yet implemented\u003c/sup\u003e\n\n\n```lua\n    function stop()\n        -- goodbye ...\n        return 0\n    end\n```\n\n## Building\n\n```shell\n  git submodule update --init --recursive\n  mkdir build\n  cd build\n  cmake ..\n  make\n```\n\n## Running your app\n\nSee the [examples](examples) and [test](test) directories for webserver\nconfiguration and example lua scripts.\n\n```shell\n  $ spawn-fcgi -p 9999 -- lua-fcgi app.lua\n  spawn-fcgi: child spawned successfully: PID: 17003  \n```\n\nFor debugging you can run the application on the command line in CGI mode:\n```shell\n  $ ./lua-fcgi app.lua\n  Lua file doesn't provide an \"accept\" function.\n```\n\nOr you can supply an environment variable named ```ERRLOG``` with the path\nto a log file:\n```shell\n  $ ERRLOG=/path/to/my.log spawn-fcgi -p 9999 -- lua-fcgi app.lua\n  spawn-fcgi: child spawned successfully: PID: 4025\n  $ cat /path/to/my.log\n  Error start function returned non-zero value: 101  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravispaul%2Flua-simple-fcgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravispaul%2Flua-simple-fcgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravispaul%2Flua-simple-fcgi/lists"}