반응형

1. 웹서버와 파이썬을 cgi라는 방법을 통해서 연동

기본적으로 아파치는 해당기능이 꺼져있음

 apaceh2/conf/httpd.conf 파일수정

LoadModule cgid_module modules/mod_chid.so 

해당 부분 주석 해제

 

2. 아파치에서 py 파일을 읽을 수 있도록 수정

 

DocumentRoot "/Applications/mampstack-8.0.1-0/apache2/htdocs"

웹서버를 진입하면 해당 디렉토리를 루트로 잡아라

<Directory "/Applications/mampstack-8.0.1-0/apache2/htdocs">
<Directory> 하단에

확장자가 py인 파일에 대한 동작을 설정

    <Files *.py>
     #CGI 기능을 활성화
     Options ExecCGI  
#확장자가 py인 파일에 대해서는 CGI로써 실행시켜라
     AddHandler cgi-script .py
    </Files>

 

3. 설정파일을 수정한 후에는 아파치를 재구동하여야 설정값이 적용 됨

 

TroubleShooting 1 : malformed header from script '~~~.py'

유효하지 않은 형식의 해더값을 스크립트에서 보내고 있다

 

=> 코드 상단에

print("content-type:text/html; charset=utf-8\n")

를 추가하여 컨텐트 타입을 정의

 

TroubleShooting 2: env: python3: No such file or directory

= >

#!/usr/bin/env python3 로 파이썬을 실행 못시키는 케이스가 발생하는것임

shell 에서

type python3

실행 후 나오는 위치를

#! 뒤에 넣어주면 됨

Posted by npre
,
반응형

환경 Mac

 

1. 파이썬 설치

www.python.org/downloads/ 에서 3.x 버젼 다운로드 설치

2. 로컬아파치를 돌리기 위해 bitnami MAMP 설치

bitnami.com/stack/mamp

3. 로컬에서 작동 확인

localhost:8080/index.html

TroubleShooting : 본 컴퓨터는 8080포트를 이미 사용하고 있으므로 8081로 포트 변경

manager-osx 실행하여 apache 포트 8081로 변경 후 재기동

4. index.html 수정하여 변경확인

mampstack-9.0.XX/apache2/htdocs 가 ROOT

5. 해당 위치에 sample py 파일 생성

hello.py

a = 1+2
b = 2+3
print(b)

6. 터미널에서 해당 위치로 가서 python3 hello.py 실행하여 확인

7. python3 명령어를 입력하지 않기 위한 작업

 - 파일 실행 권한 추가 sudo chmod a(모두에게)+x(실행권한 execute) hello.py

 - type python3 입력 후 나오는 값 확인 /usr/bin/python3

 - hello.py 파일 상단에

#!/usr/bin/python3

추가 (해당 위치의 프로그램으로 실행하여라 라는 의미)

위와 같이 작성하는 경우 피씨마다 파이썬이 설치되어있는 위치가 다를 수 있으므로 이식성이 떨어지게됨

=> 

#!#!/usr/bin/env python3

위와 같이 작성하여 unix기반에서는 범용적으로 돌 수 있도록 작성

(python3 라는 프로그램을 찾아서 실행하여라는 의미)

9. 터미널에서 ./hello.py 실행 후 작동 확인

 

'Programing' 카테고리의 다른 글

리눅스 Mysql 외부접속 셋팅  (0) 2021.04.19
[Python] 파이썬과 apache 연동  (0) 2021.01.28
Docker에 tomcat 컨테이너 올려서 WAR 돌리기  (1) 2021.01.13
mvn install trouble shooting  (0) 2021.01.12
Docker 추가 셋팅  (2) 2021.01.11
Posted by npre
,
반응형

1. docker에 tomcat8 설치

% docker run -d -it -p 8080:8080 --name test_tomcat tomcat:8

 

2. 작성 한 WAR 톰캣 컨테이너로 카피 (WAR 명은 ROOT로 정의한다.)

% docker cp ROOT.war test_tomcat:/usr/local/tomcat/webapps

 

3. 컨테이너로 접속해서 확인 (WAR 카피해서 넣으면 자동으로 배포 되는듯)

% docker exec -it test_tomcat bash

 

4. WAR 수정 배포 시 ROOT 파일만 제거 후 다시 카피해주면 자동으로 재배포됨

 

'Programing' 카테고리의 다른 글

[Python] 파이썬과 apache 연동  (0) 2021.01.28
[Python] Mac에 Python 개발환경 셋팅  (1) 2021.01.28
mvn install trouble shooting  (0) 2021.01.12
Docker 추가 셋팅  (2) 2021.01.11
Docker 초기 셋팅  (2) 2021.01.11
Posted by npre
,
반응형

IDE에서는 메이븐 인스톨이 정상적으로 잘동하는데 shell 에서 mvn install 시 아래 에러가 발생하면서 빌드가 안되는 케이스 발생

 

[ERROR] Please refer to /Users/hyun/Documents/GUIVING/Server/Git/maven.1607406660364/Guiving/target/surefire-reports for the individual test results.

[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.

 

 

 

누군가의 댓글

 

The problem was in maven-surefire-plugin version 2.20.1. It is not workin g for me even on JDK 8. After decreasing version to 2.18.1 started to work fine.

 

 

플러그인 버젼을 낮춤으로 해결

Posted by npre
,

Docker 추가 셋팅

Programing 2021. 1. 11. 19:27
반응형

1. docker build -t 등을 매번 하지 않기 위해 docker-maven plugin 추가

pom.xml 파일 참조

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.1</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.hyun</groupId>
	<artifactId>DockTest</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>DockTest</name>
	<description>Demo project for Spring Boot</description>

	<properties>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web-services</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
			  	<groupId>io.fabric8</groupId>
			  	<artifactId>docker-maven-plugin</artifactId>
			  	<version>0.34.1</version>
			  	<configuration>
			  		<images>
			  			<image>
			  				<!-- 이미지를 만들 위치 -->
			  				<name>npre/springdockertest</name>
			  				<build>
			  				<!-- Dockerfile기본 위치는 src/main 이므로 프로젝트 베이스 폴더로 위치 지정(이것이 컨벤션임) -->
			  					<dockerFileDir>${basedir}</dockerFileDir>
			  					<filter>@</filter>
			  				</build>
			  			</image>
			  		</images>
			  	</configuration>
			  	<!-- mvn package 시 build 하도록 추가 설정 -->
			  	<executions>
			  		<execution>
			  			<id>docker-build</id>
			  			<phase>package</phase>
			  			<goals>
			  				<goal>build</goal>
		  				</goals>
			  		</execution>
		  		</executions>
		  	</plugin>
		</plugins>
	</build>

</project>

2. mvn clean package 로 이미지 생성

 

3. mvn docker:push 로 docker hub로 밀어넣기

 

4. 로컬에서 해당 이미지를 삭제하더라도 hub에 있으면 자동으로 pull 해와서 런 되는 상태 확인

Posted by npre
,

Docker 초기 셋팅

Programing 2021. 1. 11. 19:21
반응형

현재까지 작업 된 Docker 적용

 

1. Local (Mac 환경)에 Docker 설치 (차 후 Linux 환경에 설치 테스트 필요), 리눅스 환경은 AWS EC2에 구성 예정

 

2. Spring Boot Web 프로젝트 신규 생성 (환경 STS4)

Create Spring Starter Project

Java version 8

Spring Boot Version 2.4.1

Dependency에

Spring Web, Spring Web Service 추가하여 생성

 

3. Project Root 위치에 Dockerfile 생성 (대소문자 주의)

내용

 

FROM openjdk:8-jre

COPY target/DockTest-*.jar app.jar

ENTRYPOINT ["java", "-jar", "app.jar"]

 

(프로젝트 명이 DockTest임)

 

4. mvn install로 DockTest-0.0.1.jar 생성 (STS maven install로 생성)

 

5. Docker 이미지 생성

터미널에서 프로젝트 Root로 이동 

% docker build -t dockertest

 

#발생한 문제

"invalid reference format: repository name must be lowercase"

repo 이름은 소문자만 가능한듯

 

Docker 이미지 생성 확인

% docker images

REPOSITORY에서 생성 된 이미지 확인

 

6. Docker에서 생성 된 이미지 컨테이너에 올리기

% docker run -d -p 8080:8080 dockertest

 

백그라운드 실행을 위해 -d 옵션, 로컬 포트와 도커 포트를 동기화 하기 위하여 8080 옵션 설정

 

 

7. 실행 후 돌고 있는 컨테이너 확인

% docker ps

 

8. 돌고있는 컨테이너 킬

ps로 확인 한 CONTAINER ID넘버로 킬

docker stop container_id

docker rm container_id

 

9. 테스트로 생성 한 도커 이미지 삭제

docker rmi dockertest

 

 

 

'Programing' 카테고리의 다른 글

mvn install trouble shooting  (0) 2021.01.12
Docker 추가 셋팅  (2) 2021.01.11
[iOS] Splash Image 파일로 셋팅할때 주의할점  (1) 2020.06.08
Spring boot message property 다국어 대응  (0) 2020.04.29
iOS 13 Modal FullScreen 이슈  (0) 2020.04.27
Posted by npre
,
반응형

iOS Splash Screen을 Storyboard를 사용하지 않고 Image Set에서 Lanch Image를 셋팅할때

Target, Build Setting에서

Asset Catalog Compiler의 LanchImage name을 셋팅해줘야함.

'Programing' 카테고리의 다른 글

Docker 추가 셋팅  (2) 2021.01.11
Docker 초기 셋팅  (2) 2021.01.11
Spring boot message property 다국어 대응  (0) 2020.04.29
iOS 13 Modal FullScreen 이슈  (0) 2020.04.27
[iOS] UserDefault Setting  (0) 2016.05.17
Posted by npre
,
반응형

App 다국어 대응 중 서버에서 내려주는 값에 대해 지역화를 진행할 필요가 있었다.

 

DB에 language code 별로 row를 추가하여 localization을 처리하는 부분도 있었으나 단순히 국가명 등의 텍스트들까지 굳이 ERD를 바꿔가며 적용을 해야하나라는 고민을 하던 중 message property를 이용하여 지역화 대응을 하게 되었다.

 

MsgConfig.java

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

@Configuration
public class MsgConfig {

	@Bean
	public MessageSource messageSource() {
		ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
		messageSource.setBasenames("message/message");
		messageSource.setDefaultEncoding("UTF-8");
		
		return messageSource;
	}
}

위와 같이 설정하여 src/main/resources/message/ 하단에

이런식으로 지역화 메세지 프로퍼티를 넣었다.

 

사용부 예시

@Autowired
MessageSource msgSource;


Srting countryName = msgSource.getMessage("KR", null, Locale.forLanguageTag("en"))

MessageSouce를 걸어주고

 

"KR"은 properties의 key 값,

LanguageTag는 어느 파일에서 값을 가져올 것인지를 결정한다

만약 LanguageTag값에 맞는 프로퍼티 파일이 없는 경우 default 프로퍼티 (message.prorperties)의 Key 값에 매핑하여 값을 가져온다.

 

프로퍼티 파일 예시

message_ko.properties

# Country Name
KR = 대한민국
PH = 필리핀
VN = 베트남

message_en.properties

# Country Name
KR = Korea
PH = Philippines
VN = Vietnam

 

'Programing' 카테고리의 다른 글

Docker 초기 셋팅  (2) 2021.01.11
[iOS] Splash Image 파일로 셋팅할때 주의할점  (1) 2020.06.08
iOS 13 Modal FullScreen 이슈  (0) 2020.04.27
[iOS] UserDefault Setting  (0) 2016.05.17
[iOS] UITableView 좌측 여백 제거  (1) 2016.04.22
Posted by npre
,
반응형

iOS 13으로 업데이트 되면서 Modal로 띄우던 VC에 대한 기본값이 수정되었다 한다.

 

이게 문제가 되는게 상단영역에 대한 스타일만 수정이 되면 괜찮은데

해당 default 값으로 모달이 뜨는경우 하단에 뷰가 남아 있는 상태로 인지되어서인지 모달로 뜬 VC를 Dismiss해도 밑에 깔려 있는 VC에서 DidAppear 등이 콜이 되지 않는 현상이 생긴다.

 

기본 설정값이나 여타 사항들은 타 블로그에 잘 설명되어있고, 

현재 개발 중이던, 운영중인 프로젝트에서 해당 변경 사항에 대하여 조치는 취해야 하니 급한대로 적용한 코드

 

        let con:ChatSelectImgViewController = ChatSB.instantiateViewController(withIdentifier: "ChatSelectImgViewController") as! ChatSelectImgViewController
        con.modalPresentationStyle = .fullScreen
        self.present(con, animated: false, completion: nil)

 

위처럼 현재 VC에서 present 할 VC의 스타일 속성을 .fullScreen으로 두어 우선은 기존의 didAppear 등의 코드가 작동하도록 처리.

 

.present 로 전체검색 후 각각 변경하는 적당한 노가다는 함..

 

Posted by npre
,
반응형

Define 정의

#define bundleObjectForKey(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]

#define bundleSetObject_forKey(id, key) [[NSUserDefaults standardUserDefaults] setObject:id forKey:key];\

[[NSUserDefaults standardUserDefaults] synchronize]

#define bundleRemoveObjectForKey(key) [[NSUserDefaults standardUserDefaults] removeObjectForKey:key];\

[[NSUserDefaults standardUserDefaults] synchronize]


CustomClass 사용


Bool

+ (void)setIsFirstLoadingChannel:(BOOL)boolValue

{

    if (boolValue == YES) {

        bundleSetObject_forKey(@"Y", USER_DEFAULT_CUSTOM_KEY)

    }else {

        bundleRemoveObjectForKey(USER_DEFAULT_CUSTOM_KEY);

    }

}


+ (BOOL)isFirstLoadingChannel

{

    BOOL isFirst = NO;

    NSString *str = bundleObjectForKey(USER_DEFAULT_CUSTOM_KEY);

    if (str != nil && [str  isEqualToString:@"Y"] == YES) {

        isFirst = YES;

    }

    return isFirst;

}


String

+ (void)setLastChannel:(NSString *)str

{

    bundleSetObject_forKey(str, USER_DEFAULT_CUSTOM_KEY);

}


+ (NSString *)lastChannel

{

    NSString *channel = bundleObjectForKey(USER_DEFAULT_CUSTOM_KEY);

    return channel;

}


Posted by npre
,