How to Pass the Path in the Systemd Unit File

Asked 2 years ago, Updated 2 years ago, 89 views


To daemonize and automatically launch server programs written in Python Until you run the supervisor on Amazon linux 2

I would like to refer to the above page and introduce supervisor on AWS EC2.

The target EC2 has pyenv in /home/ec2-user/.pyenv.
I use ec2-user's .bash_profile to pass through.
root user must pass the path or specify an absolute path to find pyenv-managed commands


Supervisor installed with pip install under this pyenv administration How do I use it in the unit file?

Re-inserting to shared files such as /usr/local may affect existing scripts, so
I would like to keep pyenv as it is if possible.

 [Unit]
Description = Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target

Service
ExecStart=source/home/ec2-user/.bash_profile;supervisord-n-c/etc/supervisord.conf
ExecStop=source/home/ec2-user/.bash_profile;supervisorctl$OPTIONS shutdown
ExecReload=source/home/ec2-user/.bash_profile;supervisorctl$OPTIONS reload
KillMode=process
Restart = on-failure
RestartSec = 50s

Install
WantedBy=multi-user.target

Try writing like this

ExecStart=/home/ec2-user/.pyenv/bin/pyenv exec supervisor-n-c/etc/supervisord.conf

I tried writing that

 sudo systemctl start supervisor

does not start the main body of supervision

Specific steps

Except that the first pip was already in it and that I put off logging, it's exactly the same as the blog I referenced

 pip install supervisor

At this point, ec2-user can use supervision, supervisorctl

 echo_supervisord_conf>supervisord.conf

Edit logfile, pidfile, include in visupervisord.conf just like blogging

 sudo mv supervisor.conf/etc/
sudo mkdir/etc/supervisord.d
sudo mkdir/var/log/supervisor/

vi/etc/systemd/system/supervisord.service
Create a file with the contents of the questionnaire in

sudo systemctl start supervisor has not started anything in ps-ef | grep supervisor

Startup Error Log

Where does build up?

/var/log/supervisor does not contain anything
(I guess the command didn't pass in the first place)

linux pyenv systemd supervisor

2022-09-30 18:01

1 Answers

#!/bin/bash
source/home/ec2-user/.bash_profile
supervisord-n-c/etc/supervisord.conf


on /home/ec2-user/bin/start_supervisord.sh with the launch script file

to ExecStart bash/home/ec2-user/bin/start_supervisord.sh
When I wrote that, it started, so I'm thinking of compromising


because it is redundant to have a service file, but to have a separate startup script. I want to be able to start with only the service file

Run this file directly and run the two lines inside; run the connected command in
I don't even know why there is a difference...


2022-09-30 18:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.