2

I used to run my pyramid server as a daemon with the pserve --daemon command.

Given that it's deprecated, I'm looking for the best replacement. This link recommends to run it with screen or tmux, but it seems too heavy to just run a web server. Another idea would be to launch it with setsid.

What would be a good way to run it ?

Eino Gourdin
  • 4,169
  • 3
  • 39
  • 67
  • 1
    Have a look at this answer: http://stackoverflow.com/a/41335348/3657941 –  Feb 16 '17 at 15:57
  • Possible duplicate of [How to move SimpleSocket server into a background process](http://stackoverflow.com/questions/41334729/how-to-move-simplesocket-server-into-a-background-process) –  Feb 16 '17 at 15:58

2 Answers2

4

Create a service file in /etc/systemd/system. Here a example (pyramid.service):

[Unit]

Description=pyramid_development
After=network.target

[Service]
# your Working dir
WorkingDirectory=/srv/www/webgis/htdocs/app
# your pserve path with ini
ExecStart=/srv/www/app/env/bin/pserve /srv/www/app/development.ini

[Install]
WantedBy=multi-user.target

Enable the service:

systemctl enable pyramid.service

Start/Stop/Restart the service with:

systemctl start pyramid.service

systemctl restart pyramid.service

systemctl stop pyramid.service

Neffets
  • 138
  • 9
2

The simplest option is to install supervisord and setup a conf file for the service. The program would just be env/bin/pserve production.ini. There are countless examples online of how to do this.

The best option is to integrate with your system's process manager (systemd usually, but maybe also upstart or sysvinit or openrc). It is very easy to write a systemd unit file for starting pserve and then it will be started/stopped along with the rest of your system. Log files are even handled automatically in these cases.

Michael Merickel
  • 23,153
  • 3
  • 54
  • 70
  • 1
    I have found supervisord to be a great solution for running/managing pyramid and other custom server sockets. One detail to be aware of is that after restarting the server, you will need to issue the command `supervisord -c /etc/supervisord.conf` to "remove the stale socket". – Tim D Feb 18 '17 at 19:36