본문 바로가기
Server/Vapor - Server_Side_Swift

Vapor 서버 만들기 - Ubuntu+Swift+Vapor+Github+Supervisor(5)

by HaningYa 2020. 8. 16.
728x90

Supervisor 를 안다니 서버가 자꾸 꺼져서 해결해야겠다.

이전에 에러는

 

 

Spawn 에러가 났었는데 로그가 남는다 해서 로그를 보았다.

 

020-08-16 05:47:08,840 INFO exited: hello (exit status 0; not expected)
2020-08-16 05:47:11,846 INFO spawned: 'hello' with pid 7321
2020-08-16 05:47:11,913 INFO exited: hello (exit status 0; not expected)
2020-08-16 05:47:12,914 INFO gave up: hello entered FATAL state, too many start retries too quickly
2020-08-16 08:49:41,363 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:49:42,367 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:49:44,371 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:49:47,376 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:49:47,377 INFO gave up: hello entered FATAL state, too many start retries too quickly
2020-08-16 08:51:33,614 CRIT Supervisor running as root (no user in config file)
2020-08-16 08:51:33,618 INFO Included extra file "/etc/supervisor/conf.d/hello.conf" during parsing
2020-08-16 08:51:33,619 INFO RPC interface 'supervisor' initialized
2020-08-16 08:51:33,620 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-08-16 08:51:33,620 INFO supervisord started with pid 26021
2020-08-16 08:51:34,621 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:51:35,624 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:51:37,627 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:51:40,632 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:51:40,633 INFO gave up: hello entered FATAL state, too many start retries too quickly
2020-08-16 08:55:13,355 CRIT Supervisor running as root (no user in config file)
2020-08-16 08:55:13,358 INFO Included extra file "/etc/supervisor/conf.d/hello.conf" during parsing
2020-08-16 08:55:13,358 INFO RPC interface 'supervisor' initialized
2020-08-16 08:55:13,359 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-08-16 08:55:13,359 INFO supervisord started with pid 26021
2020-08-16 08:55:14,360 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:55:15,363 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:55:17,365 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:55:20,439 INFO spawnerr: can't find command '/home/uuzaza74/hello/vapor'
2020-08-16 08:55:20,440 INFO gave up: hello entered FATAL state, too many start retries too quickly
2020-08-16 08:56:42,068 INFO spawned: 'hello' with pid 10203
2020-08-16 08:56:42,230 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:43,234 INFO spawned: 'hello' with pid 10210
2020-08-16 08:56:43,299 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:45,303 INFO spawned: 'hello' with pid 10217
2020-08-16 08:56:45,368 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:48,374 INFO spawned: 'hello' with pid 10224
[program:hello]
2020-08-16 08:56:48,440 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:49,236 INFO gave up: hello entered FATAL state, too many start retries too quickly
2020-08-16 08:56:49,240 INFO spawned: 'hello' with pid 10233
2020-08-16 08:56:49,305 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:50,308 INFO spawned: 'hello' with pid 10240
2020-08-16 08:56:50,374 INFO exited: hello (exit status 0; not expected)
2020-08-16 08:56:52,384 INFO spawned: 'hello' with pid 10247
2020-08-16 08:56:52,450 INFO exited: hello (exit status 0; not expected)

뭐 로그가 많이 쌓였는데 일단 잘못된 가능성이 있는 곳은 .conf 파일을 잘못 설정해서 발생하는 것 같다. 

[program:hello]
command=/home/uuzaza74/hello/vapor run --env=production
directory=/home/uuzaza74/hello/ 
autorestart=true
user=ubuntu
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log

 

일단 user 는 맞고 디렉토리도 맞다. 그런데 로그도 그렇고 Run 을 못찾는걸 보면 command 쪽이 문제인것 같다.

Vapor 사이트의 공식 예제코드를 보면

[program:hello]
command=/home/vapor/hello/.build/release/Run serve --env=production
directory=/home/vapor/hello/
user=www-data
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log

Run 이라는 명령어를 하는데 음 Run 의 경로가 잘못된 건지 확인해 봐야겠다.

일단 나는 release 라는 디렉토리가 없다.

vapor build -release 해도 에러가 나고 Run 은 debug 디렉토리에 있었다.

경로를 debug/Run 으로 바꿔보자

 

여전히 안된다 하 짜증나네 다시 로그 보자

2020-08-16 09:24:51,914 INFO supervisord started with pid 26021
2020-08-16 09:24:52,917 INFO spawned: 'hello' with pid 11491
2020-08-16 09:24:53,414 INFO exited: hello (terminated by SIGILL (core dumped); not expected)
2020-08-16 09:24:54,417 INFO spawned: 'hello' with pid 11499
2020-08-16 09:24:54,923 INFO exited: hello (terminated by SIGILL (core dumped); not expected)
2020-08-16 09:24:56,927 INFO spawned: 'hello' with pid 11506
2020-08-16 09:24:57,405 INFO exited: hello (terminated by SIGILL (core dumped); not expected)
2020-08-16 09:25:00,411 INFO spawned: 'hello' with pid 11513
2020-08-16 09:25:00,884 INFO exited: hello (terminated by SIGILL (core dumped); not expected)

 

모르겠다.

 

다음에 하련다

 

vapor 커맨드로 이것저것 하다가 이런걸 발견했다

 

혹시 디렉토리 경로가 저건가 싶다

다시해봐야겠다

conf 파일 수정하고

안된다.

 

 

 

 

 

 

터미널 꺼도 서버만 살아있게 하면 되니까 Supervisor 안쓰고 딴걸로 해봐야겠따

 

 

nohup 명령어로 어플리케이션 실행하기

nohup 은 “no hangups” 라는 의미로, 리눅스/유닉스에서 쉘 스크립트파일을 데몬 형태로 실행시키는 명령어다. 터미널이 끊겨도 실행한 프로세스는 계속 동작하게 한다.

medium.com

nohup 이라는 명령어가 있다.
프로세스를 데몬으로 돌려준다.
이걸로 vapor run 명령을 백그라운드로 실행시켜놓고 그만하련다.

 

해당 디렉토리에 nohup.out 에 로그가 찍힌다. 보면 서버가 시작된걸 볼 수 있고 이제 나는 SSH 연결을 끊어도 계속 HelloWorld 출력될 것이다. 

 

http://34.121.76.118/hello

 

 

728x90

댓글