## 第一章：铭记起义

「纵慾之城」（City of Orgies）是美国著名同性恋诗人沃尔特惠特曼于1860年创作的诗，当时诗人居住于纽约曼哈顿城区，与形形色色的人交往、恋爱。收录于《草叶集》。无奈网上未见汉译。

### City of Orgies

CITY of orgies, walks and joys!
City whom that I have lived and sung in your midst will one day make you illustrious,
Not the pageants of you—not your shifting tableaux, your spectacles, repay me;
Not the interminable rows of your houses—nor the ships at the wharves,
Nor the processions in the streets, nor the bright windows, with goods in them;
Nor to converse with learn’d persons, or bear my share in the soiree or feast;
Not those—but, as I pass, O Manhattan! your frequent and swift flash of eyes offering me love,
Offering response to my own—these repay me;
Lovers, continual lovers, only repay me.

### 纵慾之城

Supervisor is a program that, well, supervises your script and can restart them if needed. This is particularly useful for discord bot hosting, because apparently, the Websocket module that discord.py depends on may contain bugs that randomly resets the connection and there is nothing you can do about it.

Setting it up is pretty easy as well. The only caveat is that supervisor runs as the root user with some root directory as the working directory. In the start script you supply it's necessary to change to /path/to/your/program for your program to run. Here is an example set up

(/etc/supervisor/conf.d/foo.conf)

(/home/me/foo/run.sh)

Supplying absolute paths everywhere might be an overkll but it's the safe thing to do.

So all is well, until you try to stop this program. Turns out in this setting, the python program is spawned as a child process by the run.sh script process, and supervisor.d is only responsible for stopping the run.sh process, not the child process it spawns. Similarly, running supervisorctl restart foo will now create a new python program without stopping the first one.

### Solution

I know you are here for this. Add the following line

to foo.conf. Reread & update your supervisor task. From now on when the supervisor send a stop signal it will propagate to all the child processes in the same process group.

Makes sense?