가끔 이런 상황이 있습니다.
회사에서 같이 일하는 분이 특정 고객사의 웹사이트를 확인해야 하는데,
그 사이트가 해외에 있어서 접속이 될 때도 있고 안될 때도 있는 상태였습니다.
그래서 그분이 하고 있던 작업이 뭐였냐면…
브라우저 새로고침 → 접속 안됨 브라우저 새로고침 → 접속 안됨 브라우저 새로고침 → 접속 안됨 브라우저 새로고침 → 접속됨!
이걸 몇 분 동안 계속 반복하고 계시더라고요.
옆에서 보다가 문득 생각했습니다.
“이거 사람이 할 일이 아닌데?”
그래서 바로 바이브 코딩으로 하나 만들어 봤습니다.
바이브 코딩으로 만든 작은 해결책
제가 만든 건 아주 단순한 앱입니다.
사이트가 살아나면 알려준다
동작 방식은 이렇습니다.
1. 특정 URL을 입력
2. 일정 주기마다 사이트 체크
3. HTTP 200 / 301 / 302 응답 확인
4. 사이트가 살아나면 알림
5. 바로 브라우저 열기
사용자는 그냥 기다리면 됩니다.
왜 AppleScript로 만들었나
마침 제가 쓰고 있는 환경이 Mac이었습니다.
Mac에서는 AppleScript로 이런 장점이 있습니다.
- 간단한 코드로 macOS 앱으로 바로 빌드 가능
- 백그라운드 실행 가능
- macOS 알림(Notification) 바로 사용 가능
- 추가 설치 필요 없음
그래서 10분 만에 동작하는 앱이 만들어졌습니다.
프롬프트
TCREI 프레임워크로 정교하게 하고 싶었지만, 늘 그렇듯 여러번의 프롬프트로 다듬어서 모델링을 한 뒤 지저분한 것들을 걷어내고 리팩토링 프롬프트를 만들었습니다.
# 역할: 전문 애플스크립트(AppleScript) 개발자
# 목표: 특정 URL의 활성화 여부를 주기적으로 체크하고 알림을 주는 'Stay-open' 방식의 애플리케이션 스크립트 작성
# 요구 사항:
1. **상태 체크 로직**: `curl -L -I` 명령어를 사용하여 HTTP 응답 코드가 200, 301, 302 중 하나인지 확인합니다.
2. **백그라운드 실행**: `on idle` 핸들러를 사용하여 사용자가 설정한 주기(초 단위, 최소 5초)마다 반복 실행되어야 합니다.
3. **설정 저장**: 입력한 URL과 체크 주기는 `defaults write` 명령어를 통해 사용자 환경 설정(`com.user.sitewatcher`)에 영구 저장되고, 앱 실행 시 `defaults read`로 불러와야 합니다.
4. **사용자 인터페이스**:
- 앱 첫 실행 시 URL과 주기가 없으면 입력창을 띄웁니다.
- 사이트 접속이 가능해지면 푸시 알림을 보내고, 브라우저로 바로 열지 묻는 대화창을 띄웁니다.
- 알림 후에는 모니터링을 자동으로 중단(`set monitoring to false`)합니다.
- `on reopen` 핸들러를 통해 앱 아이콘 클릭 시 '시작', '중지', '설정 변경' 메뉴를 제공합니다.
5. **예외 처리**:
- 네트워크 미연결 시 에러로 중단되지 않고 다음 주기에 재시도하도록 `try` 문을 구성합니다.
- 구문 오류(특히 "라인의 끝 발견" 등)가 발생하지 않도록 명령어 간 줄 바꿈과 핸들러 독립 구조를 엄격히 지킵니다.
# 출력 형식:
- 주석이 포함된 전체 코드.
- 스크립트 에디터에서 '애플리케이션' 및 '실행 후 열기 유지' 옵션으로 저장하는 방법 안내.
결과물
(*
SiteWatcher - URL 상태 모니터링 AppleScript
요구 기능
- curl -L -I 로 HTTP 상태 코드 체크
- on idle 기반 주기 실행
- defaults 로 설정 저장/불러오기
- 사이트 활성화 시 알림 + 브라우저 열기
- reopen 시 메뉴 제공
*)
-- 설정
property prefsDomain : "com.user.sitewatcher"
property targetURL : ""
property intervalSec : 30
property monitoring : false
property alreadyNotified : false
------------------------------------------------------------
-- 앱 실행
------------------------------------------------------------
on run
my loadSettings()
if targetURL is "" then
my askSettings()
end if
set monitoring to true
set alreadyNotified to false
display notification "사이트 상태 추적 시작" with title "SiteWatcher"
end run
------------------------------------------------------------
-- idle 루프 (Stay-open 앱의 핵심)
------------------------------------------------------------
on idle
if monitoring is false then
return 10
end if
try
-- HTTP 상태 코드 확인
set cmd to "curl -L -I -s --connect-timeout 5 " & quoted form of targetURL & " | head -n 1"
set resultLine to do shell script cmd
if resultLine contains "200" or resultLine contains "301" or resultLine contains "302" then
if alreadyNotified is false then
set alreadyNotified to true
set monitoring to false
display notification "사이트 접속 가능" with title "SiteWatcher"
activate
set userChoice to button returned of (display dialog "사이트 접속이 가능합니다." buttons {"닫기", "브라우저로 열기"} default button "브라우저로 열기")
if userChoice is "브라우저로 열기" then
open location targetURL
end if
end if
end if
on error
-- 네트워크 오류 등은 무시하고 다음 주기에 재시도
end try
return intervalSec
end idle
------------------------------------------------------------
-- 앱 아이콘 클릭 시 메뉴
------------------------------------------------------------
on reopen
set userChoice to button returned of (display dialog "SiteWatcher 메뉴" buttons {"시작", "중지", "설정 변경"} default button "시작")
if userChoice is "시작" then
set monitoring to true
set alreadyNotified to false
display notification "모니터링 시작" with title "SiteWatcher"
else if userChoice is "중지" then
set monitoring to false
display notification "모니터링 중지" with title "SiteWatcher"
else if userChoice is "설정 변경" then
my askSettings()
end if
end reopen
------------------------------------------------------------
-- 설정 입력
------------------------------------------------------------
on askSettings()
try
set urlInput to text returned of (display dialog "확인할 URL 입력" default answer targetURL)
set intervalInput to text returned of (display dialog "체크 주기(초)" default answer intervalSec)
set intervalNum to intervalInput as integer
if intervalNum < 5 then
set intervalNum to 5
end if
set targetURL to urlInput
set intervalSec to intervalNum
my saveSettings()
on error
display dialog "설정 입력이 취소되었습니다."
end try
end askSettings
------------------------------------------------------------
-- 설정 저장 (defaults write)
------------------------------------------------------------
on saveSettings()
try
do shell script "defaults write " & prefsDomain & " url " & quoted form of targetURL
do shell script "defaults write " & prefsDomain & " interval -int " & intervalSec
on error
end try
end saveSettings
------------------------------------------------------------
-- 설정 불러오기 (defaults read)
------------------------------------------------------------
on loadSettings()
try
set targetURL to do shell script "defaults read " & prefsDomain & " url"
end try
try
set intervalSec to (do shell script "defaults read " & prefsDomain & " interval") as integer
end try
if intervalSec < 5 then
set intervalSec to 5
end if
end loadSettings
프로세스 구조
앱 실행
↓
URL / 주기 로드
↓
on idle 루프 시작
↓
curl -L -I URL
↓
HTTP 200/301/302 확인
↓
알림 + 브라우저 열기 여부 질문
↓
모니터링 자동 중단
스크립트 저장 방법 (중요)
내보내기 - 파일포멧:응용 프로그램 (옵션 모두 체크) 후 저장

아주 작은 불편일 수 있지만, 지나칠 수 없어 만들어 보았습니다.
다운로드 아래의 링크를 이용해 주세요.
'필요해서 Make IT > 바이브 코딩' 카테고리의 다른 글
| AI코드 편집기 Cursor 1.0 정식 업데이트 소식 및 변경사항 (5) | 2025.06.12 |
|---|---|
| Cursor + Smithery 로 알아본 MCP 기능 리뷰 (1) | 2025.06.01 |
| 바이브 코딩 경험담 및 커서&클라인 사용 후기 (0) | 2025.05.27 |
| GPT, 좋은 결과를 얻기 위한 프롬프트 작성방법 (0) | 2024.11.25 |
