{"id":1203,"date":"2025-07-25T14:59:17","date_gmt":"2025-07-25T05:59:17","guid":{"rendered":"https:\/\/qer.kr\/?p=1203"},"modified":"2025-07-25T15:30:54","modified_gmt":"2025-07-25T06:30:54","slug":"%eb%94%94%ec%8a%a4%ec%bd%94%eb%93%9c-%eb%b4%87","status":"publish","type":"post","link":"https:\/\/qer.kr\/?p=1203","title":{"rendered":"\ub514\uc2a4\ucf54\ub4dc \ubd07"},"content":{"rendered":"\n<p>cd ~\/discordbot<\/p>\n\n\n\n<p>python3 -m venv venv &amp;&amp; source venv\/bin\/activate<\/p>\n\n\n\n<p>python bot.py<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. \uac00\uc0c1\ud658\uacbd\u00b7\uacbd\ub85c \ud655\uc778<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\ubcf5\uc0ac\ud3b8\uc9d1<code>\/home\/ubuntu\/discordbot\/\n    \u251c\u2500\u2500 venv\/          # python -m venv \ub85c \ub9cc\ub4e0 \uacf3\n    \u2514\u2500\u2500 bot.py\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\ub2e4\ub978 \uc704\uce58\u00b7\uc0ac\uc6a9\uc790\ub77c\uba74 \uacbd\ub85c\u00b7User \ud56d\ubaa9\ub9cc \ub9de\ucdb0 \ubc14\uafd4 \uc8fc\uc138\uc694.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. \uc11c\ube44\uc2a4 \uc720\ub2db \ud30c\uc77c \uc791\uc131<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\ubcf5\uc0ac\ud3b8\uc9d1<code>sudo nano \/etc\/systemd\/system\/discordbot.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">ini\ubcf5\uc0ac\ud3b8\uc9d1<code>[Unit]\nDescription=Discord Party Bot\nAfter=network.target\n\n[Service]\n# \ubd07\uc744 \uc2e4\ud589\ud560 \ub9ac\ub205\uc2a4 \uacc4\uc815\nUser=ubuntu\nWorkingDirectory=\/home\/ubuntu\/discordbot\n\n# \uac00\uc0c1\ud658\uacbd \ud30c\uc774\uc36c\uc73c\ub85c bot.py \uc2e4\ud589\nExecStart=\/home\/ubuntu\/discordbot\/venv\/bin\/python \/home\/ubuntu\/discordbot\/bot.py\n\n# \ud45c\uc900 \ucd9c\ub825\u00b7\uc624\ub958\ub97c journald \ub85c\nStandardOutput=journal\nStandardError=inherit\n\n# \ud504\ub85c\uc138\uc2a4\uac00 \uc8fd\uc73c\uba74 10\ucd08 \ud6c4 \uc790\ub3d9 \uc7ac\uc2dc\uc791\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n\n\n\n<p><strong>\uc800\uc7a5 \u2192 Ctrl + O, Enter \u2192 Ctrl + X \uc885\ub8cc<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. systemd \uc5d0 \ub4f1\ub85d\u00b7\uc2dc\uc791<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\ubcf5\uc0ac\ud3b8\uc9d1<code>sudo systemctl daemon-reload          # \uc720\ub2db \uc0c8\ub85c\uace0\uce68\nsudo systemctl enable discordbot      # \ubd80\ud305 \uc2dc \uc790\ub3d9 \uc2e4\ud589\nsudo systemctl start  discordbot      # \uc9c0\uae08 \uc989\uc2dc \uc2e4\ud589\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\uc0c1\ud0dc\u00b7\ub85c\uadf8 \ud655\uc778<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\ubcf5\uc0ac\ud3b8\uc9d1<code>sudo systemctl status discordbot      # \uc2e4\ud589\/\uc5d0\ub7ec \uc0c1\ud0dc\njournalctl -u discordbot -f           # \uc2e4\uc2dc\uac04 \ub85c\uadf8 tail\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. \ucf54\ub4dc \uc5c5\ub370\uc774\ud2b8 \uc2dc \uc7ac\uc2dc\uc791\ub9cc \ud558\uba74 \ub428<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">bash\ubcf5\uc0ac\ud3b8\uc9d1<code># git pull \ub610\ub294 \ud30c\uc77c \uc218\uc815 \ud6c4\nsudo systemctl restart discordbot\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. \ud658\uacbd\ubcc0\uc218(.env) \uc704\uce58 \uc8fc\uc758<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>.env<\/code> \uac00 <strong>WorkingDirectory<\/strong> \uc548\uc5d0 \uc788\uc73c\uba74 \uadf8\ub300\ub85c \uc77d\ud799\ub2c8\ub2e4.<\/li>\n\n\n\n<li>\ub9cc\uc57d <code>\/etc\/environment<\/code> \uac19\uc740 \uc804\uc5ed \ud658\uacbd\ubcc0\uc218\ub97c \uc4f0\uace0 \uc2f6\ub2e4\uba74<br>\uc11c\ube44\uc2a4 \uc720\ub2db\uc5d0 <code>Environment=\"DISCORD_TOKEN=...\"<\/code> \uc904\uc744 \ucd94\uac00\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>cd ~\/discordbot python3 -m venv venv &amp;&amp; source venv\/bin\/activate python bot.py 1. \uac00\uc0c1\ud658\uacbd\u00b7\uacbd\ub85c \ud655\uc778 bash\ubcf5\uc0ac\ud3b8\uc9d1\/home\/ubuntu\/discordbot\/ \u251c\u2500\u2500 venv\/ # python -m venv \ub85c \ub9cc\ub4e0 \uacf3 \u2514\u2500\u2500 bot.py \ub2e4\ub978 \uc704\uce58\u00b7\uc0ac\uc6a9\uc790\ub77c\uba74 \uacbd\ub85c\u00b7User \ud56d\ubaa9\ub9cc \ub9de\ucdb0 \ubc14\uafd4 \uc8fc\uc138\uc694. 2. \uc11c\ube44\uc2a4 \uc720\ub2db \ud30c\uc77c \uc791\uc131 bash\ubcf5\uc0ac\ud3b8\uc9d1sudo nano \/etc\/systemd\/system\/discordbot.service ini\ubcf5\uc0ac\ud3b8\uc9d1[Unit] Description=Discord Party Bot After=network.target [Service] # \ubd07\uc744 \uc2e4\ud589\ud560 \ub9ac\ub205\uc2a4 \uacc4\uc815 User=ubuntu WorkingDirectory=\/home\/ubuntu\/discordbot # \uac00\uc0c1\ud658\uacbd \ud30c\uc774\uc36c\uc73c\ub85c bot.py \uc2e4\ud589 ExecStart=\/home\/ubuntu\/discordbot\/venv\/bin\/python \/home\/ubuntu\/discordbot\/bot.py # \ud45c\uc900 \ucd9c\ub825\u00b7\uc624\ub958\ub97c journald \ub85c StandardOutput=journal StandardError=inherit # \ud504\ub85c\uc138\uc2a4\uac00 \uc8fd\uc73c\uba74 10\ucd08 \ud6c4 \uc790\ub3d9 \uc7ac\uc2dc\uc791 Restart=always RestartSec=10 [Install] WantedBy=multi-user.target \uc800\uc7a5 \u2192 Ctrl + O, Enter \u2192 Ctrl + X \uc885\ub8cc 3. systemd \uc5d0 \ub4f1\ub85d\u00b7\uc2dc\uc791 bash\ubcf5\uc0ac\ud3b8\uc9d1sudo systemctl daemon-reload # \uc720\ub2db \uc0c8\ub85c\uace0\uce68 sudo systemctl enable discordbot # \ubd80\ud305 \uc2dc \uc790\ub3d9 \uc2e4\ud589 sudo systemctl start discordbot # \uc9c0\uae08 \uc989\uc2dc \uc2e4\ud589 \uc0c1\ud0dc\u00b7\ub85c\uadf8 \ud655\uc778 bash\ubcf5\uc0ac\ud3b8\uc9d1sudo systemctl status discordbot # \uc2e4\ud589\/\uc5d0\ub7ec \uc0c1\ud0dc journalctl -u discordbot -f # \uc2e4\uc2dc\uac04 \ub85c\uadf8 tail 4. \ucf54\ub4dc \uc5c5\ub370\uc774\ud2b8 \uc2dc \uc7ac\uc2dc\uc791\ub9cc \ud558\uba74 \ub428 bash\ubcf5\uc0ac\ud3b8\uc9d1# git pull \ub610\ub294 \ud30c\uc77c \uc218\uc815 \ud6c4 sudo systemctl restart discordbot 5. \ud658\uacbd\ubcc0\uc218(.env) \uc704\uce58 \uc8fc\uc758<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1203","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/posts\/1203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qer.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1203"}],"version-history":[{"count":2,"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/posts\/1203\/revisions"}],"predecessor-version":[{"id":1205,"href":"https:\/\/qer.kr\/index.php?rest_route=\/wp\/v2\/posts\/1203\/revisions\/1205"}],"wp:attachment":[{"href":"https:\/\/qer.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qer.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qer.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}