Plack and systemd

385 views
Skip to first unread message

Dan Axtell

unread,
Jul 10, 2017, 2:13:08 PM7/10/17
to psgi-plack
I have some Plack apps for REST API's that I can launch via plackup or start_server if want to daemonize and control them.  The target server I'm going to run them on is Centos 7 which encourages using systemd.  I'd like the apps to launch on reboot and be controllable via the systemctl command like other services.

I've tried a simple unit file like this:

[Unit]
Description=Kelp API PSGI app
After=network.target

[Service]
ExecStart=/usr/bin/plackup -E deployment -p 8081 -s Starman --max-workers=2 app.psgi
User=www-data
WorkingDirectory=/usr/local/www/kelp/ajax_api/

[Install]
WantedBy=multi-user.target


However, this fails to launch, I get this error:
Jul 10 13:59:35 p4904302.pubip.peer1.net systemd[1]: Started Kelp API plack.
Jul 10 13:59:35 p4904302.pubip.peer1.net systemd[1]: Starting Kelp API plack...
Jul 10 13:59:35 p4904302.pubip.peer1.net systemd[123826]: Failed at step USER spawning /usr/bin/plackup: No such process
Jul 10 13:59:35 p4904302.pubip.peer1.net systemd[1]: kelp-api.service: main process exited, code=exited, status=217/USER
J

/usr/bin/plackup exists; I've tried using start_server as a wrapper around plackup in the ExecStart line, but that fails also. 

I've also tried using uwsgi to serve the application, and while it works from the command line it doesn't seem to work with systemd either.

Does anyone have any examples of how this should work?

Thanks.

Thomas Klausner

unread,
Jul 10, 2017, 4:47:51 PM7/10/17
to psgi-...@googlegroups.com
Hi!

On Mon, Jul 10, 2017 at 11:13:08AM -0700, Dan Axtell wrote:
> I've tried a simple unit file like this:

here's a unit file from one of our servers (but I don't really know anything about systemd, our sysadmin generated this file using ansible...)

I replace some live paths/etc with $foo.
And instead of '/usr/bin/carton exec' you could use the path to plackup, if you installed it systemwide.

----begin----

[Service]
WorkingDirectory=/srv/$service-name/current/$repo/
ExecStart=/usr/bin/carton exec plackup -p 5050 --no-default-middleware -s Starman --workers 20 bin/api.psgi
Type=simple
Restart=always
User=$service-api
Group=$servicewxl-api
StartLimitInterval=0

[Install]
WantedBy=multi-user.target

---- end ----


So IMO this looks quite similar to what you have, so no idea if this is helpful at all..

> Jul 10 13:59:35 p4904302.pubip.peer1.net systemd[123826]: Failed at step
> USER spawning /usr/bin/plackup: No such process

Can you run the command in ExecStart form the command line?

greetings,
domm


--
#!/usr/bin/perl http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
Reply all
Reply to author
Forward
0 new messages