Skip to content

Instantly share code, notes, and snippets.

@steinkel
Created January 19, 2018 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinkel/774d1d249f085580c91150b247cd6bfc to your computer and use it in GitHub Desktop.
Save steinkel/774d1d249f085580c91150b247cd6bfc to your computer and use it in GitHub Desktop.
create socket shell in ubuntu to feed a cakephp shell
in /etc/systemd/system/cakesocket.socket
[Unit]
Description=Cakesocket example
[Socket]
ListenStream=8088
Accept=yes
[Install]
WantedBy=sockets.target
in /etc/systemd/system/cakesocket@.service
[Unit]
Description=Cakesocket service example
[Service]
ExecStart=-/usr/bin/php /tmp/app/bin/cake.php listener
StandardInput=socket
then bake a new app under /tmp/app
bin/cake bake shell listener
vi /tmp/app/src/Shell/ListenerShell.php
modify main method
public function main($data = null)
{
$input = $this->in('?');
echo $input;
}
then do
sudo systemctl daemon-reload && sudo systemctl enable cakesocket.socket && sudo systemctl start cakesocket.socket && sudo systemctl status cakesocket.socket
check status is OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment