Question

Add Systemd Service on the Digital App Platform

Hi, we are using Symfony app and it is deployed to the App Platform. One of the components that we are using is the Symfony Messenger. This component acts like a async worker on the background where it runs long running queries. One of the options to keep the worker running on the background is to use the systemd. Messenger: Sync & Queued Message Handling (Symfony Docs)

“Systemd user service configuration files typically live in a ~/.config/systemd/user directory. For example, you can create a new messenger-worker.service file. Or a messenger-worker@.service file if you want more instances running at the same time:”

[Unit]
Description=Symfony messenger-consume %i

[Service]
ExecStart=php /path/to/your/app/bin/console messenger:consume async --time-limit=3600
Restart=always
RestartSec=30

[Install]
WantedBy=default.target

I tried this using the App Platform console but unfortunately, I don’t have permission to do so and if I remember correctly, the next deployment resets everything back to default.

My question is, how can we create a systemd on the Digital App Platform?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 16, 2024
Accepted Answer

Hi there,

Indeed, creating custom systemd services would require root access to the underlying infrastructure which you get only with Droplets.

With the App Platform, you could just use a worker instead:

https://docs.digitalocean.com/products/app-platform/how-to/manage-workers/

Background workers can consist of any application code you like. As far as App Platform is concerned, they are the same as services, except they are not routable, meaning they are not accessible via an external URL.

You can add an additional worker component to your existing app and just run the console command:

php /path/to/your/app/bin/console messenger:consume async --time-limit=3600

That way the App Platform and the worker will be responsible for running that process which is basically the alternative of running this as a systemd service on a standalone server.

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel