서비스가 수동으로 시작된 경우 launchd를 통해 서비스를 중지할 수 있습니까?

서비스가 수동으로 시작된 경우 launchd를 통해 서비스를 중지할 수 있습니까?

부팅 시 mysql을 시작하기 위해 launchd를 사용하고 있는데 잘 작동합니다. 'launchctl unload' 및 'launchctl load' 명령을 사용하여 서비스를 중지하고 시작할 수 있습니다. 또한 터미널에 'mysqld_safe' 명령을 입력하여 서비스를 시작할 수 있습니다. 하지만 'launchctl stop'을 통해 서비스를 중지한 후 'mysqld_safe' 명령을 통해 서비스를 시작하면 'launchctl stop'을 통해 서비스를 중지할 수 없습니다. 이것이 가능한가? 내가 여기서 뭘 잘못하고 있는 걸까요?

내 Plist는 다음과 같습니다

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>mysql.service</string>
        <key>ProgramArguments</key>
        <array>
                <string>/path/to/mysql/bin/mysqld_safe</string>
                <string>--defaults-file=/path/to/mysql/my.cnf</string>
                <string>--port=3306</string>
                <string>--socket=/path/to/mysql/tmp/mysql.sock</string>
                <string>--datadir=/path/to/mysql/data</string>
                <string>--log-error=/path/to/mysql/data/mysqld.log</string>
                <string>--pid-file=/path/to/mysql/data/mysqld.pid</string>
       </array>
       <key>RunAtLoad</key>
       <true/>
       <key>KeepAlive</key>
       <false/>
       <key>UserName</key>
       <string>_mysql</string>
       <key>GroupName</key>
       <string>_mysql</string>
    <key>StandardOutPath</key>
    <string>/tmp/mysql_start.out</string>
    <key>StandardErrorPath</key>
    <string>/tmp/mysql_start.err</string>

</dict>
</plist>

터미널을 통해 mysql을 시작하는 데 사용되는 명령은 다음과 같습니다.

mysqld_safe --defaults-file=/path/to/mysql/my.cnf --port=3306 --socket=/path/to/mysql/tmp/mysql.sock --datadir=/path/to/mysql/data --pid-file=/path/to/mysql/data/mysqld.pid

답변1

이는 의도된 동작입니다. launchctl stop로드되지 않은 작업에 대한 발행은 작동하지 않습니다.

관련 정보